The input element value is updated by the @bind event in Blazor. To get the current input value, use the oninput native event of the input element and get the current input value.
<input type="text" @bind="@inputValue" @oninput="OnInputEvent" />
@inputValue
@code {
private string inputValue = "Hello, world";
private void OnInputEvent(ChangeEventArgs changeEvent)
{
inputValue = (string)changeEvent.Value;
}
}
Share with