Is it possible to make one master page simply include another master page?
是否可以使一个母版页只包含另一个母版页?
I have three master pages, which have converged in content, and I want to make 2 of them point to the third, so that the content is not replicated, but leaving them in so that they can change easily in the future if they have to.
我有三个主页,它们已融合在内容中,我想让它们中的两个指向第三个,这样内容就不会被复制,而是留下它们,以便将来如果必须的话,它们可以很容易地改变。
1 个解决方案
#1
Yes, what you need is called nested master pages. Just set the MasterPageFile
in the <%@ Master %>
directive of child master pages to the parent one.
是的,您需要的是所谓的嵌套母版页。只需将子页面母版页的<%@ Master%>指令中的MasterPageFile设置为父页面。
Main.Master:
<%@ Master Language="C#" %>
.... shared content ....
<asp:ContentPlaceHolder ID="C" runat="server" />
First.Master:
<% Master Language="C#" MasterPageFile="Main.Master" %>
<asp:Content runat="server" ContentPlaceHolderID="C">
.... Some content ....
<asp:ContentPlaceHolder ID="AnotherPlaceholder" runat="server" />
</asp:Content>
Second.Master:
<% Master Language="C#" MasterPageFile="Main.Master" %>
<asp:Content runat="server" ContentPlaceHolderID="C">
.... Some other content ....
<asp:ContentPlaceHolder ID="AnotherPlaceholder" runat="server" />
</asp:Content>
#1
Yes, what you need is called nested master pages. Just set the MasterPageFile
in the <%@ Master %>
directive of child master pages to the parent one.
是的,您需要的是所谓的嵌套母版页。只需将子页面母版页的<%@ Master%>指令中的MasterPageFile设置为父页面。
Main.Master:
<%@ Master Language="C#" %>
.... shared content ....
<asp:ContentPlaceHolder ID="C" runat="server" />
First.Master:
<% Master Language="C#" MasterPageFile="Main.Master" %>
<asp:Content runat="server" ContentPlaceHolderID="C">
.... Some content ....
<asp:ContentPlaceHolder ID="AnotherPlaceholder" runat="server" />
</asp:Content>
Second.Master:
<% Master Language="C#" MasterPageFile="Main.Master" %>
<asp:Content runat="server" ContentPlaceHolderID="C">
.... Some other content ....
<asp:ContentPlaceHolder ID="AnotherPlaceholder" runat="server" />
</asp:Content>