Render bootstrap dropdown menu with in c# MVC3 Html.ActionLink

空扰寡人 提交于 2019-12-06 00:33:34

No need to reinvent the wheel. With TwitterBootstrapMVC desired output is achieved with the following syntax:

@using (var dd = Html.Bootstrap().Begin(new DropDown("Dropdown").SetLinksActiveByControllerAndAction()))
{
    @dd.ActionLink("Action1", "index", "controller1")
    @dd.ActionLink("Action2", "index", "controller2")
}

Notice the extension method SetLinksActiveByControllerAndAction(). That's what makes links active based on current controller/action.


Disclaimer: I'm the author of TwitterBootstrapMVC.

You need to purchase a license if working with Bootstrap 3. For Bootstrap 2 it's free.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!