Hello,
I have a form which contains some validators attached to TextBoxes.
The form also contains a dropbox which does not have any validator. If a user select an item in the dropbox and then submits the form the InvalidSubmit callback is called.
The reason why InvalidSubmit callback is called is that when the form calls EditContext.Validate(); it throws the following exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'obj')
at System.OrdinalCaseSensitiveComparer.GetHashCode(String obj)
at Microsoft.AspNetCore.Components.Forms.FieldIdentifier.GetHashCode()
at System.Collections.Generic.Dictionary2.FindValue(TKey key)
at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value)
at Microsoft.AspNetCore.Components.Forms.ValidationMessageStore.Clear(FieldIdentifier& fieldIdentifier)
at Radzen.Blazor.ValidatorBase.ValidateModel(Object sender, ValidationRequestedEventArgs args)
at Microsoft.AspNetCore.Components.Forms.EditContext.Validate()
Does anybody have an idea would could be the problem?
Thanks for the response. I just wanted to strip the code to the bare minimum. In my code the problem occurs even if the @bind-Value is used. Hm, but yes in this example when @bind-Value is there it works. So I need to investigate more.
Thanks again for your response. It focused me in right direction.
I have finally found the problem and for the sake of completeness here is the resolution:
I had wrapped the RadzenTextBox into my special text box. The special text box was updating Value after each character as the user was typing. Therefore it was not necessary to @bind-Value - because the value update was happening via the @oninput callback.
The declaration was like this: