Live Chat Icon For mobile
Live Chat Icon

How do you bind and handle events?

Platform: Blazor| Category : Data binding, Event handling

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)
       {
           ...
       }
   }  

Refer to this Blazor documentation for more information.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.