0

my requirement is as below. I have a header with the following links: Home, Destinations, Seasons. I want the Destinations link to be a drop down list(containing links Attractions and Popular destinations) on hover. I know how to implement this using html, css and bootstrap, but since im using mvc, navigating to the action method in the controller would be a problem. Below is the code ive got so far. Have no clue how to implement the dropdown list. Please help!

<div class="menu">
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active">@Html.ActionLink("Home", "Index", "Home")</li>

                    <li>

                        <ul class="dropdown-menu" aria-labelledby="dropdownmenu1">
                            <li>@Html.ActionLink("Activities", "Activities", "Home")</li>
                            <li>@Html.ActionLink("Popular Destinations","Destinations","Home")</li>
                        </ul>
                    </li>
                <li>@Html.ActionLink("Seasons", "Seasons", "Home")</li>
            </ul>
            </div>
        </div> 

I want the links 'Activities' and 'Popular Destinations' to be in the dropdown list of the header link 'Destinations'. Please advice how to achieve this using bootstrap and html helper actionlink.

Mvc Learner
  • 189
  • 2
  • 3
  • 16

2 Answers2

0

You should use-

@Html.DropDownListFor(model => model.YourModelName, listItems, "-- Select Value--")

For more detail, Please refer:- DropDownList in MVC 4 with Razor

Community
  • 1
  • 1
Priya
  • 1,359
  • 6
  • 21
  • 41
0

Try this below html

<div class="menu">
    <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
            <li class="active">@Html.ActionLink("Home", "Index", "Home")</li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                    Destinations 
                    <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <li>@Html.ActionLink("Activities", "Activities", "Home")</li>
                    <li>@Html.ActionLink("Popular Destinations","Destinations","Home")</li>
                </ul>
            </li>
            <li>@Html.ActionLink("Seasons", "Seasons", "Home")</li>
        </ul>
    </div>
</div>
Krunal Mevada
  • 1,637
  • 1
  • 17
  • 28