Reputation: 1756
I want to navigate a user from one page to another page and automatically scroll to a specific anchor on the site.
However, blazor redirects me but the requestes anchor is ignored. Does anybody know how I can achive this?
In my app, the user becomes redirected within the code behind file of my razor component.
NavigationManager.NavigateTo($"/Lagerregal/Auftrag/{Belegnummer}#{Position.BPOS_N_POSID + Position.UrlParameter}");
Thanks in advance! Marvin
Upvotes: 1
Views: 2226
Reputation: 738
Henk Holterman commented blog is really nice. If you want to navigate without using JavaScript you can try this -
@inject NavigationManager Nav;
<a @onclick="OnChanged"> Section 1 </a>
<a href="@Nav.BaseUri/Descriptions#section2"> Section 2 </a>
void OnChanged(MouseEventArgs e)
{
Nav.NavigateTo($"{Nav.BaseUri}/Descriptions#section1");
}
@page "/Descriptions"
<h3 id="section1">Section 1</h3>
<p>This is first Section</p>
<h3 id="section2">Section 2</h3>
<p>This is second Section</p>
Upvotes: 2