I have been using Blazor and I encountered an issue could not find any solution. I have been trying to add text into input fields but it's not updating.
@page "/"<PageTitle>Form</PageTitle><h1 style="text-align:center">Form & Validation</h1><EditForm Model="person" OnValidSubmit="FormSubmit" FormName="Form"><DataAnnotationsValidator /><label>Name :</label><InputText id="name" @bind-Value="person.Name" /><br /><br /><button type="submit" class="btn btn-primary">submit</button></EditForm><p>New Name : @person.Name</p>@code { Person person = new Person(); string displaySuccess, styleColor; private void FormSubmit() { displaySuccess = "Worked!"; styleColor = "Green"; } class Person { public string? Name { get; set; } }}I tried
private void FormSubmit(){ if (person != null) { displaySuccess = "Worked!"; styleColor = "Green"; } else { displaySuccess = "Wrong!"; styleColor = "red"; }}Then it always shows "Worked!" even though it was null what is happening?
I tried looking up on Google didn't find anything dunno why my value is not getting updated