ASP.NET主页面文件导致错误
我正在尝试在我的网站中使用母版页。我创建了一个页面,然后创建了母版。然后我添加了标记MasterPageFile=“~/master”。我猜我需要对我的主页做些什么,因为我现在开始出现错误:ASP.NET主页面文件导致错误,asp.net,master-pages,Asp.net,Master Pages,我正在尝试在我的网站中使用母版页。我创建了一个页面,然后创建了母版。然后我添加了标记MasterPageFile=“~/master”。我猜我需要对我的主页做些什么,因为我现在开始出现错误: The page contains markup that is not valid when attached to a master page 我的主页如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.asp
The page contains markup that is not valid when attached to a master page
我的主页如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/my.master" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
我试图删除标签,认为这可能是问题所在。有人能给我指出正确的方向吗?母版页中的页面应该有
您需要将正文更改为内容部分。母版页使用内容占位符
:内容页需要为这些占位符提供内容
引用上述链接,您的母版页可能包含以下内容:
<td><asp:contentplaceholder id="Main" runat="server" /></td>
内容页将通过提供以下内容来填充
<% @ Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
主要内容。
注意,我在内容页的顶部包含了主声明