This is my Index.razor Page.
@page "/"
@inject NavigationManager navigation
<PageTitle>Index</PageTitle>
<div class="login-page">
<div class="form">
<div class="login">
<div class="login-header">
<h3>LOGIN</h3>
<p>Please enter your credentials to login.</p>
</div>
</div>
<form class="login-form">
<input type="text" placeholder="username"/>
<input type="password" placeholder="password"/>
<button @onclick=ValidateCredentials>login</button>
</form>
</div>
</div>
@code{
protected override async Task OnInitializedAsync()
{
}
public void ValidateCredentials(EventArgs e)
{
navigation.NavigateTo("/fetchdata");
}
}
When I click on Login button over the UI the fetchdata pages pops but immediately the index.razor pages comes back eg Onclick from Index.razor ->fetchdata.razor(it appears for millisecond)-->index.razor login uI starts showing.
Please guide me what am I doing wrong.I am very new to Blazor but i guess this (It could onclick event call from html form I might to use Editcontext model )