<button @onclick="() => { counter += 1; }">Button1</button> <button @onclick="Increment1">Button2</button> <button @onclick="Increment2">Button2</button> <div> <span>Count : </span> <span>@counter</span> </div> @code { private int counter = 0; private void Increment1() { counter += 1; } private async Task Increment2() { await Task.Delay(1000); counter += 1; } }
References
https://docs.microsoft.com/en-us/aspnet/core/blazor/components/event-handling