Reputation: 119
In Blazor Server App / .NET 6 preview 4 (same for .NET 5) I would like to handle onchange event and in certain cases to dismiss user input with setting a certain value to the textbox. There is a basic code for demonstation:
<input value="@tester" @onchange="@OnChangeHandler" />
@code {
public string tester { get; set; }
public void OnChangeHandler(ChangeEventArgs obj)
{
tester = "100";
}
}
For some reason input shows "100" only once even though the property tester
is set each time when OnChangeHandler
fired. input keeps a value entered by the user ignoring the fact that tester
is set to "100" when onchange
occurs second and third time. How can I make input always contain actual value of tester
?
Upvotes: 1
Views: 1224
Reputation: 939
A quick dirty workaround would be something like this :
public async Task OnChangeHandler(ChangeEventArgs obj)
{
tester =null;
await Task.Delay(1);
tester = "100";
}
it's not good a fix is planned in the preview 5 of dotnet6
Upvotes: 2