Olivier Muhring

Olivier Muhring

  • 1.9k
  • 147
  • 3.3k

How do I add a a dropdown menu in the default asp .net 3.1 razor templ

Sep 9 2020 11:35 PM
By default, when you create a page in asp .net core 3.1 (in Visual Studio of course) you get a base menus in _layout.cshtml:
  1. <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">    
  2.     <div class="container">    
  3.         <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Axinco.JuryTool.Interface.Gui</a>    
  4.         <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"    
  5.                 aria-expanded="false" aria-label="Toggle navigation">    
  6.             <span class="navbar-toggler-icon"></span>    
  7.         </button>    
  8.         <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">    
  9.             <partial name="_LoginPartial"/>    
  10.             <ul class="navbar-nav flex-grow-1">    
  11.                 <li class="nav-item">    
  12.                     <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>    
  13.                 </li>    
  14.                 <li class="nav-item">    
  15.                     <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>    
  16.                 </li>    
  17.             </ul>    
  18.         </div>    
  19.     </div>    
  20. </nav>  
This gives you the following layout:
 
 
I added code to download extra menu settings based on the role. Basically, it's a menuheader (for example 'Adminisrator') and then a couple of menu items.
 
So I want to add a down menu next to "Privacy".
 
How would I best do this?

Answers (1)