I'm working on my first Blazor project for training purpose, and I'm facing a page lifecycle behavior that I can explain.
Starting with the Blazor App Server project template, I have added a simple page on witch I place some button on like this
<button class="col-1 btn btn-light btn-sm bg-transparent navButton" onclick="@GotoNext()">Next</button>
protected async Task GotoNext()
{
// Some code ..
}
But for some reason all button onclick event get triggered on page load and each time the method StateHasChanged get call.
How's that? How to work around this? Is this normal? So much question ...
Thanks to you for reading
OK I figure it out. My event registration wasn't good. The event should be assign like
@onclick="GotoNext"
NOT like
onclick="@GotoNext()"