Simple example of drop down menu with a sub menu using razor
12,806
It sounds like you want the following?
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")
<ul>
<li>@Html.ActionLink("subItem1", "SubItemOne", "Home")</li>
<li>@Html.ActionLink("subItem2", "SubItemTwo", "Home")</li>
</ul>
</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</nav>
Author by
Ben Junior
C# (since first version) VS 2013 2017 2019 NETCORE 3.1 ASP.NET 4.1 MVC 3,4 and 5 BLAZOR MSSQL HTML CSS JQuery Bootstrap 4 WPF Delphi Pascal
Updated on July 18, 2022Comments
-
Ben Junior almost 2 years
I searched the net looking for a way to add "subItem1" and "subItem2" to the "Home" item menu (in the sample code bellow), but what I found uses either java or complex razor examples. Is there a simpler way using razor only?
<nav> <ul id="menu"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> </nav>