Live Chat Icon For mobile
Live Chat Icon

How do I pass arguments to the onclick event in Blazor?

Platform: Blazor| Category: Event handling

You can use a lambda expression to pass multiple arguments to an onclick event.

@for(var i=0; i<5; i++) {
     var index = i;
     <button @onclick="@(e => click(index, 5 * index))">Button @i</button>
@code {
     private void click(int a, int b) {
         Console.WriteLine(a + b);

Share with

Related FAQs

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

Please submit your question and answer.