How do you bind and handle events?
Jun 06, 2021
Blazor,
ASP .NET Core Blazor,
Blazor FAQ,
bind events balzor,
handle events blazor,
1367 Views
This code will help you to understand how to bind and handle events.
You can bind events to DOM elements started with the on<event> with a delegate-type value. The attribute’s name always starts with “on.” In the following code example, the “UpdateHeading” event is triggered when the button is clicked.
<button class="btn btn-primary" @onclick="@UpdateHeading">
Update heading
</button>
@code {
private void UpdateHeading(MouseEventArgs e)
{
...
}
}
I would suggest you check the below link for better understanding:
https://docs.microsoft.com/en-in/aspnet/core/blazor/components?view=aspnetcore-3.0#event-handling