内容控件必须在内容页或顶层控制引用母版页的嵌套母版页 [英] Content controls have to be top-level controls in a content page or a nested master page that references a master page
本文介绍了内容控件必须在内容页或顶层控制引用母版页的嵌套母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用嵌套母版页,所以我创建以下的母版页:
<%@大师LANGUAGE = C#AutoEventWireup =真正的代码隐藏=test.master.cs继承=DocumentFlowUI.test的MasterPageFile =〜/ MasterPage2.master%GT;
< DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional! DTD>
< HTML的xmlns =http://www.w3.org/1999/xhtml>
<头=服务器>
<标题>< /标题>
< ASP:的ContentPlaceHolder ID =头=服务器>
< / ASP:&的ContentPlaceHolder GT;
< /头>
<身体GT;
<表ID =form1的=服务器>
< DIV>
< ASP:的ContentPlaceHolder ID =ContentPlaceHolder1=服务器>
< ASP:按钮的ID =Button1的=服务器文本=按钮/>
< / ASP:&的ContentPlaceHolder GT;
< / DIV>
< /表及GT;
< /身体GT;
< / HTML>
和我创建了以下网页使用主页:
<%@页标题=LANGUAGE =C#的MasterPageFile =〜/ test.MasterAutoEventWireup =真正的代码隐藏=WebForm4.aspx.cs继承=DocumentFlowUI.WebForm4%GT;
< ASP:内容ID =内容1ContentPlaceHolderID =头=服务器>
< / ASP:内容>
< ASP:内容ID =内容2ContentPlaceHolderID =ContentPlaceHolder1=服务器>
< ASP:标签ID =Label1的=服务器文本=标签>< / ASP:标签>
< / ASP:内容>
我收到以下错误:
内容控件必须是顶层控制在内容页或引用母版页
$一个
嵌套母版页b $ b 块引用>
解决方案在您的嵌套母版的HTML代码必须用ASP包裹:内容标签与来自contentplaceholderid 大师母版。
I want to use nested master page so i create the following master page :
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="test.master.cs" Inherits="DocumentFlowUI.test" MasterPageFile="~/MasterPage2.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"> <head runat="server"> <title></title> <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> <asp:Button ID="Button1" runat="server" Text="Button" /> </asp:ContentPlaceHolder> </div> </form> </body> </html>
and i create the following page to use that master page :
<%@ Page Title="" Language="C#" MasterPageFile="~/test.Master" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="DocumentFlowUI.WebForm4" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </asp:Content>
I get the following error :
Content controls have to be top-level controls in a content page or a nested master page that references a master page
解决方案The HTML-code in your nested masterpage must be wrapped with an asp:content-tag with a contentplaceholderid from the "master" masterpage.
这篇关于内容控件必须在内容页或顶层控制引用母版页的嵌套母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文