Issue—Blazor ValueChanged event did not fire with built-in input elements.
<EditForm Model="person"> <DataAnnotationsValidator /> <div class="form-group"> <label for="name">Name</label> <InputText ValueChanged="@ValueChange" Value="@person.FirstName" ValueExpressions= "@( () => @person.FirstName )" Class="form-control" Id="name" /> </div> </EditForm> @code { Person person = new Person(); public void ValueChange() { Console.WriteLine(person.FirstName); } }
Instead, you can also use the OnValidSubmit form event to get and process the value.
<EditForm Model="person" OnValidSubmit="@ValueChange"> <DataAnnotationsValidator /> <div class="form-group"> <label for="name">Name</label> <InputText @bind-Value="@person.FirstName" Class="form-control" Id="name" /> </div> </EditForm> @code { Person person = new Person(); public void ValueChange() { Console.WriteLine(person.FirstName); } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Instead, you can also use the OnValidSubmit form event to get and process the value.
need an explanation for this answer? contact us directly to get an explanation for this answer