http://www.metabuilders.com/ 的MasterPages 控件可以多重嵌套
http://www.metabuilders.com/ 的MasterPages 控件可以多重嵌套。这也就是 Community Server 中,非首页的其他页面的工作原理。
下面由代码来演示这个功能:
Default.aspx
<%@ Page Language="C#" %>
<%@ Register TagPrefix="mp" Namespace="MetaBuilders.WebControls.MasterPages" Assembly="MetaBuilders.WebControls.MasterPages" %>
<mp:contentcontainer runat="server" id="MPContainer" MasterPageFile="~/CurrMaster.ascx">
<mp:content id="MasterContent" runat="server">
这是Default.aspx 的内容
</mp:content>
</mp:contentcontainer>
CurrMaster.ascx
<%@ Control %>
<%@ Register TagPrefix="mp" Namespace="MetaBuilders.WebControls.MasterPages" Assembly="MetaBuilders.WebControls.MasterPages" %>
<mp:contentcontainer runat="server" id="MPContainer" MasterPageFile="~/Master.ascx">
<mp:content id="MasterContent" runat="server">
这是CurrMasterContent 的内容
</mp:content>
<mp:content id="CurrMasterContent" runat="server">
CurrMasterContent
</mp:content>
</mp:contentcontainer>
Master.ascx
<%@ Register TagPrefix="mp" Namespace="MetaBuilders.WebControls.MasterPages" Assembly="MetaBuilders.WebControls.MasterPages" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<mp:nobugform runat="server" ID="Nobugform1">
<h1>This Is In BasicMaster</h1>
<hr>
<mp:region id="MasterContent" runat="server">Default Content</mp:region>
<hr>
<h1>This Is In BasicMaster</h1>
<hr>
<mp:region id="CurrMasterContent" runat="server">Default CurrMasterContent</mp:region>
</mp:nobugform>
</body>
</html>
页面的效果如下图: