Live Chat Icon For mobile
Live Chat Icon

How do I get event data in Blazor?

Platform: Blazor| Category: Event handling

Blazor provides a set of event argument types that map to events. By using this event argument types we can get the event data for the specific event. For example, you need to use KeyboardEventArgs to get the event data for the keypress event in the input element for every key press.

 <input type="text" @onkeypress="@KeyPressed" />
  
 @code {
   private void KeyPressed(KeyboardEventArgs args)
   {
     Console.WriteLine(args.Key + " was pressed");
   }
 } 

Refer to this Visual Studio Magazine link for more events and event args.

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.