@inject NavigationManager N
<button type="button" @onclick="Nav">test</button>
@code
{
private void Nav()
{
N.NavigateTo("/t");
}
}
I have the razor file with @page "/t"
.
I clicked the test button, but nothing happened - why?
Is that the entire code of your blazor component? If you didn't add the render mode globally, then you need to add the code below for each component.
@rendermode InteractiveServer
for Blazor server@rendermode InteractiveWebAssembly
for Blazor WASM@rendermode InteractiveAuto
for hybrid@rendermode InteractiveServer
@inject NavigationManager N
<button type="button" @onclick="Nav">test</button>
@code
{
private void Nav()
{
N.NavigateTo("/t");
}
}