【发布时间】:2009-05-28 17:02:32
【问题描述】:
我想要一个使用子母版页的页面,填写父级的内容占位符,但我无法让它工作。每当我尝试时,都会收到错误消息“在母版页 '/templates/info.master' 中找不到 ContentPlaceHolder 'customHead',请在内容页面中验证内容控件的 ContentPlaceHolderID 属性。”
我有一个这样定义的母版页 (/templates/main.master):
<%@ Master Language="C#" %>
<head runat="server">
<title>foo</title>
<asp:contentplaceholder runat="server" id="customHead" />
</head>
<body>
<div id="content">
<asp:contentplaceholder runat="server" id="masterContent" />
</div>
然后我有一个这样定义的子主 (/templates/info.master):
<%@ Master Language="C#" MasterPageFile="/templates/main.master" %>
<asp:content id="homeContent" contentPlaceHolderId="masterContent" Runat="server">
<div id="info-container">
<div id="info-content">
<asp:contentplaceholder runat="server" id="infoContent"/>
</div>
</div>
</asp:content>
最后我的页面是这样定义的:
<%@ Page Language="C#" MasterPageFile="/templates/info.master" %>
<asp:Content ID="head" ContentPlaceHolderID="customHead" runat="server">
<!-- Custom header area -->
<link rel="stylesheet" type="text/css" href="foo.css"/>
</asp:Content>
<asp:Content ID="content" ContentPlaceHolderID="childContent" runat="server">
This is my child content
</asp:Content>
【问题讨论】:
标签: asp.net master-pages