Blazor how to pass arguments to onclick function?

Try it with a lambda. You're binding the onclick to the result of the function rather than the function itself.

@for (int i = 0; i < 10; i++)
{
    var buttonNumber = i;
    <button @onclick="@(e => test(buttonNumber, 5 * buttonNumber))">Check</button>
}

I try this and worked

@onclick="(() => FunctionName(argument))"

like

@onclick="(() => GetDetail(item.UserId))"

Got idea from https://github.com/aspnet/AspNetCore/issues/15956 .

Tags:

C#

Blazor