我目前正在一个团队中执行一个ASP.NET项目。团队成员无处不在,因此我们正在为分配的每个不同任务创建不同的项目。但是我们希望在项目中有一个通用的顶部导航菜单,我们已经为通用菜单创建了母版页。我们将母版页添加为每个项目的链接,但是存在一个错误,不允许我们继续执行ContentPlaceHolderID。它说“无法在当前的一个或多个母版页中找到'Maincontent'”,能告诉我代码中有什么错误吗?.Im使用Microsoft Visual Studio Community 2017和.Net framework 4.5.2
浏览器从IIS服务器中预览错误
解析器错误消息:无法使用前导..退出顶层目录。
源错误:
第1行:<%@页面标题=“”语言=“ C#” MasterPageFile =“ ../ Site1.Master” AutoEventWireup =“ true” CodeBehind =“ UserRole.aspx.cs” Inherits =“ user_role.user_role”%>行 2:第3行:
源文件:/UserRole.aspx行:1
母版页
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"
Inherits="WebApplication17.Site1" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title><asp:ContentPlaceHolder ID="title" runat="server"></asp:ContentPlaceHolder></title>
<link href="css/sidenav.css" rel="stylesheet" />
<link href="css/topnav.css" rel="stylesheet" />
<link href="css/default.css" rel="stylesheet" />
<script src="javascript/topnav.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="javascript/mainmenu.js"></script>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Nunito">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href="css/accordian.css" rel="stylesheet" />
<script src="javascript/accordian.js"></script>
<script src="javascript/myTopnav.js"></script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body style="background:#e5e5e5;">
<form id="form1" runat="server">
<%-- TOPNAV --%>
<div id="topmain" class="main" style="overflow-x: hidden;">
<div id="myTopnav" class="topnav">
<div>
<style>
.menubtn{
background-color:#1F4764;
border: none;
color: white;
font-size: 13pt;
cursor: pointer;
float:left;
padding: 15px 10px 10px 20px ;
align-content:center;
height:100%;
}
/* mouse-over */
.menubtn:hover {
color:cadetblue;
}
</style>
</div>
<nav>
<a class="menubtn" onclick="openNav()"><i class="fa fa-bars"></i></a>
<a class=' topbtn faa-parent animated-hover' href="Home.aspx"><i class='fa fa-book faa-wrench'></i><br /> Home</a>
<a class=' topbtn faa-parent animated-hover' href="Configuration.aspx"><i class='fa fa-cogs faa-wrench'></i><br /> Configuration</a>
<a href="javascript:void(0);" style="color:white; float:right; padding:15px 5px 5px 5px;" class="icon" onclick="myFunction()"><i class="fa fa-ellipsis-v"></i></a>
<asp:LinkButton ID="LinkButton1" runat="server" class=' topbtn faa-parent animated-hover' style="text-decoration:none; color:white;" ><i class='fa fa-sign-out faa-wrench'></i><br />Logout</asp:LinkButton>
</nav>
</div>
</div>
<%-- SIDENAV --%>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()" style="font-size:18pt; margin-top:5px;"><i class=" fa fa-ship faa-float animated"></i> CTMS <i class="fa fa-times-circle-o"></i></a>
<div id="accordian">
<input type="text" placeholder="Search.." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
<ul>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-book faa-wrench'></i>Documentation</a></h3>
<ul>
<li><a style="text-align:justify;" href="#">Container</a></li>
<li><a style="text-align:justify;" href="#">Supervisor Module</a></li>
<li><a style="text-align:justify;" href="#">Booking</a></li>
<li><a style="text-align:justify;" href="#">EDI</a></li>
<li><a style="text-align:justify;" href="#">Analytics</a></li>
<li><a style="text-align:justify;" href="#">Billing</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-line-chart faa-wrench'></i>Planning</a></h3>
<ul>
<li><a style="text-align:justify;" href="#"> Yard Planning</a></li>
<li><a style="text-align:justify;" href="#">Vessel Planning</a></li>
<li><a style="text-align:justify;" href="#">MT Storage Planning</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-sliders faa-wrench'></i>Control</a></h3>
<ul>
<li><a style="text-align:justify;" href="#">Yard Control</a></li>
<li><a style="text-align:justify;" href="#">Vessel Control</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#"><i class='fa fa-wrench faa-wrench' ></i>Operation</a></h3>
<ul>
<li><a style="text-align:justify;" href="#">Gate Operation</a></li>
<li><a style="text-align:justify;" href="#">Yard Operation</a></li>
<li><a style="text-align:justify;" href="#">Vessel Operation</a></li>
<li><a style="text-align:justify;" href="#">Queue Management</a></li>
<li><a style="text-align:justify;" href="#">Reefer Services</a></li>
<li><a style="text-align:justify;" href="#">CFS</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-dashboard faa-wrench'></i>Insights</a></h3>
<ul>
<li><a style="text-align:justify;" href="#">Dashboard</a></li>
<li><a style="text-align:justify;" href="#">Enquiry</a></li>
<li><a style="text-align:justify;" href="#">Reports</a></li>
<li><a style="text-align:justify;" href="#">Statistics</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-briefcase faa-wrench'></i>Resources</a></h3>
<ul>
<li><a style="text-align:justify;" href="#"> Equipment Management</a></li>
<li><a style="text-align:justify;" href="#">Incentive</a></li>
<li><a style="text-align:justify;" href="#">Setup</a></li>
</ul>
</li>
<li class="accordian">
<h3><a style="text-align:justify;" href="#" ><i class='fa fa-cogs faa-wrench'></i>Configuration</a></h3>
<ul>
<li><a style="text-align:justify;" href="#">System Maintenance</a></li>
<li><a style="text-align:justify;"href="#">System Administration</a></li>
</ul>
</li>
</ul>
</div>
</div>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("topmain").style.marginLeft = "250px";
document.getElementById("bodyframe").style.marginLeft = "285px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("topmain").style.marginLeft = "0";
document.getElementById("bodyframe").style.marginLeft = "0";
}
</script>
<div id="bodyframe" class="bodyframe" style="overflow-x: hidden;">
<asp:ContentPlaceHolder ID="Maincontent" runat="server" >
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
网页Home.aspx
<%@ Page Title="" Language="C#" MasterPageFile="../Site1.Master" AutoEventWireup="true" CodeBehind="UserRole.aspx.cs" Inherits="user_role.user_role" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="Maincontent">
<%--<div class="jumbotron">--%>
<div class="form-horizontal">
<h4><span style= "vertical-align:middle; width:80%; display: inline-block;"><%: Title %></span>
</h4>
</asp:Content>