Hi @Phrone ,
Now I have one page where I want to have a different navbar. Lets say "TopMenu2".
How can I do this?
In the MainLayout.razor
component, you could use NavigationManager
to get the current request url, then use an @if
statement to check whether it is in the specified page, and then show the different menu. Code like this:
@inherits LayoutComponentBase
@inject NavigationManager MyNavigationManager
<div class="page">
<div class="sidebar">
@if (MyNavigationManager.Uri.Contains("counter"))
{
<NavMenu2 />
}
else
{
<NavMenu />
}
</div>
<main>
<div class="top-row px-4 auth">
<LoginDisplay />
<a href="https://learn.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
The result like this:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion