Bootstrap Drop down navigation in MVC

41,469
<li class="@ActiveLink("Home", "Home", null) dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
        Storage
        <span class="caret"></span>
    </a>
    <ul class="dropdown-menu" role="menu">
        <li>@Html.ActionLink("Storage", "Add", "Storage")</li>
        <li>@Html.ActionLink("Storage", "View", "Storage")</li>
    </ul>
</li>

See the bootstrap site for more information

Share:
41,469

Related videos on Youtube

rikket
Author by

rikket

Updated on July 09, 2022

Comments

  • rikket
    rikket almost 2 years

    I have the following navigation on MVC using bootstrap, how can I make the Storage Menu Link (second li ) as a drowndown to include Add and View Links without removing the @ActionLink?

    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="brand" href="/Home/Home">News Library</a>
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        <li class="@ActiveLink("Home", "Home", null)">@Html.ActionLink("Home", "Home", "Home")</li>
                        <li class="@ActiveLink("About", "Home", null)">@Html.ActionLink("Storage", "Add", "Storage")</li>
                        <li class="@ActiveLink("Contact", "Home", null)">@Html.ActionLink("Activites", "Add", "Activites")</li>
                        <li class="@ActiveLink("Contact", "Home", null)">@Html.ActionLink("Search", "Index", "Search")</li>
                    </ul>
                    <ul class="nav pull-right">
                        <li>@Html.ActionLink("[Log Out]", "Logout", "Home")</li>
                    </ul>                
                </div>
            </div>
        </div>
    </div>
    
    • Mister Epic
      Mister Epic almost 10 years
      "How can I make the storage as a dropdown..." Your request is unclear.
    • Raghuveer
      Raghuveer almost 10 years
      @rikket Do you mean you want to show another dropdown when you hover second link?
  • sandeep.gosavi
    sandeep.gosavi over 5 years
    It is giving me error as Uncaught Error: Syntax error, unrecognized expression: # I am using bootstrap 3.3.7