Here is the html:
<EditForm Model="Input" method="post" OnValidSubmit="LoginUser" FormName="login" Enhance><DataAnnotationsValidator /><div id="SubmitDiv"><InputText @bind-Value="Input.Email" class="ant-input SubmitContentInput" autocomplete="username" aria-required="true" placeholder="@_Localizer["ErrorMessageUserNameRequire"]" /><ValidationMessage For="() => Input.Email" class="ant-form-item-explain-error" /><InputText @bind-Value="Input.Password" type="password" class="ant-input SubmitContentInput" autocomplete="current-password" aria-required="true" placeholder="@_Localizer["ErrorMessagePasswordRequire"]" /><ValidationMessage For="() => Input.Password" class="ant-form-item-explain-error" /></div> </EditForm>And here is the model:
[SupplyParameterFromForm] private InputModel Input { get; set; } = new(); private sealed class InputModel { [EmailAddress(ErrorMessageResourceName = "ErrorMessageEMailVerify", ErrorMessageResourceType = typeof(TuskyPhoenix.Resources.Components.Account.Pages.Login))] [Required(ErrorMessageResourceName = "ErrorMessageUserNameRequire", ErrorMessageResourceType = typeof(TuskyPhoenix.Resources.Components.Account.Pages.Login))] public string Email { get; set; } = ""; [Required(ErrorMessageResourceName = "ErrorMessagePasswordRequire", ErrorMessageResourceType = typeof(TuskyPhoenix.Resources.Components.Account.Pages.Login))] [DataType(DataType.Password)] public string Password { get; set; } = ""; }And here is the code to set the value:
protected override async Task OnAfterRenderAsync(bool firstRender){ if (firstRender) { var _uriBuilder = new UriBuilder(_NavigationManager.Uri); var _query = System.Web.HttpUtility.ParseQueryString(_uriBuilder.Query); var _result = _query["UserName"]; if (_result is { }) { Input.Email = _result; } }}When the user input the URL "https://localhost:1434/Account/login?UserName=abc@Gmail.com"
It can get the query parameter abc@Gmail.com successfully.
However, after setting the value of Input.Email to the query parameter, the UI doesn't change any.
What I actually want to do is to input the email by URL.
What's wrong with my code? Is it only a one-way binding? How can I implement this?