Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to trigger navigationManager.LocationChanged upon clicking links that change URL fragment or hash in Blazor 8?

$
0
0

In a Blazor 7 web assembly project, _navigationManager_LocationChanged of the following code is being triggered after clicking the links (Login, Sign Up, or Forgot Password). The same event is not being triggered in Blazor 8.

@page "/"@inject NavigationManager _navigationManager@implements IDisposable<h1>Hello, world!</h1><a href="#login">Login</a> |<a href="#signup"> Sign Up</a> |<a href="#forgotpassword">Forgot Password</a>@code {    protected override void OnInitialized()    {        _navigationManager.LocationChanged += _navigationManager_LocationChanged;        base.OnInitialized();    }    void _navigationManager_LocationChanged(object sender, LocationChangedEventArgs e)    {        Console.WriteLine("_navigationManager_LocationChanged: " + e.Location);    }    void IDisposable.Dispose()    {        _navigationManager.LocationChanged -= _navigationManager_LocationChanged;    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>