我在打开不在根文件夹中的页面的折叠菜单时遇到问题。导航栏是母版页的一部分,它可以在根文件夹中的所有页面上正常工作,但当页面位于子文件夹中时,打开折叠菜单的按钮将不响应(例如:对于./Default,菜单出现折叠时,按钮会按预期下拉菜单,但是对于./Admin/Default,菜单可见,但是当它被折叠时按钮没有响应)。由于它是母版页代码的一部分,我不明白为什么这只出现在某些页面上。
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits`="MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form runat="server">
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="/Default.aspx" class="navbar-brand">SLPL Automated Circulation System</a>
</div>
<!-- Everything you want hidden at 940px or less, place within here -->
<div id="navbar" class="navbar-collapse collapse">
<div class="navbar-header">
<asp:Menu ID="menu_Master" runat="server" EnableViewState="false" IncludeStyleBlock="false" Orientation="vertical" StaticMenuStyle-CssClass="nav navbar-nav" StaticSelectedStyle-CssClass="active" DynamicMenuStyle-CssClass="dropdown dropdown-menu" DataSourceID="SiteMapDataSource1"></asp:Menu>
</div>
<ul class="nav navbar-nav navbar-right">
<li>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="~/Default.aspx" />
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</div>
<footer>
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
//to fix collapse mode width issue
$(".nav li,.nav li a,.nav li ul").removeAttr('style');
//for dropdown menu
$(".dropdown-menu").parent().removeClass().addClass('dropdown');
$(".dropdown>a").removeClass().addClass('dropdown-toggle').append('<b class="caret"></b>').attr('data-toggle', 'dropdown');
//remove default click redirect effect
$('.dropdown-toggle').attr('onclick', '').off('click');
});
</script>
<script src="js/bootstrap.min.js"></script>
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</form>