母版页中的引导程序菜单在目录中的内容/子页面中不起作用

时间:2014-06-29 12:05:10

标签: asp.net twitter-bootstrap

MasterPage中有Bootstrap菜单,它在页面中完美地工作在根目录中,而目录中的页面不会填充下拉菜单。

  

http://localhost:3739/ServicePortal/Default.aspx (menu dropdown works
> perfectly)

,而

  

http://localhost:3739/ServicePortal/RegisteredUserPage/DataForm.aspx (menu drop down does not render/work)

母版页Bootstrap菜单代码如下:

<div class="container">  

    <nav class="navbar navbar-default navbar-orange" role="navigation">
    <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNav">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">O.S.L</a>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="myNav">
        <ul class="nav navbar-nav">
            <li><asp:HyperLink runat="server" ID="HomeHyperLink" NavigateUrl="~/Default.aspx" Text="Home"/></li>

            <li class="dropdown">
                <%--<asp:HyperLink runat="server" ID="HyperLink10" NavigateUrl="" Text="Services" class="dropdown-toggle" data-toggle="dropdown"></asp:HyperLink>--%> 
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Services <b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl="#" Text="Education Services"/></li>
                    <li><asp:HyperLink runat="server" ID="HyperLink2" NavigateUrl="#" Text="Health Services"/></li>
                    <li><asp:HyperLink runat="server" ID="HyperLink3" NavigateUrl="#" Text="Bank Services"/></li>
                    <li><asp:HyperLink runat="server" ID="HyperLink4" NavigateUrl="#" Text="Hotels/Restaurents"/></li>
                    <li><asp:HyperLink runat="server" ID="HyperLink5" NavigateUrl="#" Text="Wedding Halls"/></li>
                    <li><asp:HyperLink runat="server" ID="HyperLink6" NavigateUrl="#" Text="Shops"/></li>
                </ul>
            </li>
            <li><asp:HyperLink runat="server" ID="HyperLink7" NavigateUrl="#" Text="Add Services"/></li>
            <li><asp:HyperLink runat="server" ID="HyperLink8" NavigateUrl="#" Text="Contact us"/></li>
            <li><asp:HyperLink runat="server" ID="HyperLink9" NavigateUrl="#" Text="About us"/></li>
        </ul>

        <ul class="nav navbar-nav navbar-right">

            <li><asp:HyperLink runat="server" ID="hylink" NavigateUrl="~\Registration.aspx" Text="Register"/></li>

           <li class="dropdown">
            <a class="dropdown-toggle" href="#" data-toggle="dropdown"> <asp:Label ID="lab_loginStatus" runat="server" Text="Sign In"></asp:Label><strong class="caret"></strong></a>
            <div class="dropdown-menu" style="width:250px">
                <div class="loginfrm">
                    <!-- Login form here -->
                    <asp:TextBox ID="tbx_SignInName" runat="server" CssClass="form-control txtfocus-orange" placeholder="Sign In Name or Email"></asp:TextBox>
                    <asp:TextBox ID="tbx_SignInPassword" runat="server" TextMode="Password" CssClass="form-control txtfocus-orange" placeholder="Password"></asp:TextBox>
                    <div class="checkbox">
                        <asp:CheckBox ID="chkbox_SignInRememberMe" Text="Remember me" runat="server" />
                         <asp:Button ID="btn_SignIn" runat="server" CssClass="btn btn-orange pull-right" Text="Sign In" OnClick="btn_SignIn_Click" CausesValidation="false"/> 
                    </div>

                   <%-- <div class="horizentalDivider"></div>
                    <h6><asp:Label ID="lab_NotRegYet" runat="server" Text="Not Registered yet?"></asp:Label></h6>
                    <asp:LinkButton ID="link_SignUp" runat="server" Text="Register Now"></asp:LinkButton>--%>
                    <asp:Button ID="btn_Signout" runat="server" CssClass="btn btn-orange pull-right" Text="Sign Out" onClick="btn_Signout_Click" Visible="false" CausesValidation="false"/> 
                </div>
            </div>
           </li>
        </ul>
    </div><!-- /.navbar-collapse -->
    </div><!-- /.container -->

请在这方面帮助我

2 个答案:

答案 0 :(得分:1)

尝试在src中使用ResolveUrl()

<script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Common/jquery-1.7.1.min.js") %>"></script>
<script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Common/jquery-ui-1.8.18.custom.min.js") %>"></script>

答案 1 :(得分:0)

根据您在评论中提供的链接,我认为您需要在链接的开头添加波浪号和斜杠,以表明这些文件夹位于站点的根目录中。否则,浏览器会在您的网页所在的子文件夹中查找它们。这是它应该是什么样子:

<link href="~/CSS/bootstrap.css" rel="stylesheet" /> 
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
<script src="~/JavaScript/jquery-2.1.0.js"></script> 
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="~/JavaScript/bootstrap.min.js"></script> 
<script src="~/JavaScript/jquery.min.js"></script> 
<script src="~/JavaScript/jquery.mobile.customized.min.js">
</script>