Bootstrap ASP.net MVC下拉菜单不可见

时间:2013-06-25 09:20:00

标签: html5 twitter-bootstrap drop-down-menu

这是为网站生成菜单的部分视图。

<div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav" >
                @foreach (var menu in Model)
                {
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">@menu.DisplayName</a>
                        @foreach (var menuitem in menu.MenuItems)
                        {
                            <ul class="dropdown-menu" >
                                <li class="dropdown">@Html.ActionLink(menuitem.DisplayName, menuitem.ActionName, menuitem.ControllerName, new { tabindex = "-1" })</li>
                            </ul>
                        }
                    </li>
                }
            </ul>
        </div>

菜单可见,实际上下拉菜单也在HTML中创建,如下所示

<div class="navbar-inner">
    <div class="container">

        <div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav">
                    <li class="dropdown open">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">Training</a>
                            <ul class="dropdown-menu">
                                <li class="dropdown"><a tabindex="-1" href="/TTS.UI/Menu?Length=18">Attendance Confirmation</a></li>
                            </ul>
                    </li>
                    <li class="dropdown">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">ePARCS</a>
                            <ul class="dropdown-menu">
                                <li class="dropdown"><a tabindex="-1" href="/TTS.UI/Menu?Length=12">Upload</a></li>
                            </ul>
                    </li>
            </ul>
        </div>
    </div>
</div>

out out在GUI中显示如下

enter image description here

关于此问题是什么。

1 个答案:

答案 0 :(得分:1)

  1. 确保您已在该页面上包含bootstrap.js文件。
  2. 你的标记有点偏。下拉菜单中的<li>不应包含“下拉列表”
  3. 这是jsFiddle - &gt; http://jsfiddle.net/abrudtkuhl/GYSuY/

    这是基于您的示例

    的标记
    <div class="navbar">
        <div class="navbar-inner">
            <div class="container">
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        <li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#">Training</a>
    
                            <ul class="dropdown-menu">
                                <li><a tabindex="-1" href="/TTS.UI/Menu?Length=18">Attendance Confirmation</a>
    
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown"> <a data-toggle="dropdown" class="dropdown-toggle" href="#">ePARCS</a>
    
                            <ul class="dropdown-menu">
                                <li> <a tabindex="-1" href="/TTS.UI/Menu?Length=12">Upload</a>
    
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>