Possible Duplicates:
Are there nested master pages in ASP.NET MVC?
Creating nested master pages in ASP.NET Web Application
Duplicate
Are there nested master pages in ASP.NET MVC?
您能否在 ASP.NET MVC 中拥有一个从另一个主视图继承的主视图?
我的理由是:我有一些页面需要简单地继承一个非常基本的 masterview,其中包含我的页眉、页脚,没有其他内容。
但是,我也有很多页面不仅需要它,而且还需要边框图像和围绕内容的容器。我可以有一个从第一个基本主视图继承的辅助主视图吗?
这样我可以:
基本主视图 - 仅包含页眉、页脚
Second Master View - 继承 Basic Master View 并拥有自己的内容(某些页面需要)
有些 View 只是继承了基本的主视图,比如我们的着陆页
一些 View 继承自辅助 View ,它也应该包含基本主视图。
masterview 是否可以实现多级继承?
MasterPages 确实可以有MasterPages。这是一个 MSDN article关于使用“嵌套”母版页。它的工作原理与 Pages 几乎相同 - 在 <%@ Master %>
中指令,只需像在页面上一样指向 MasterPageFile,然后输入 <asp:Content ... >
区域。
在中间 MasterPage 上您希望有占位符的地方,像在顶级 Master 上一样插入它们。这是一个简单的例子:
<%@ Master MasterPageFile="~/TopMaster.master" %>
<asp:Content runat="server" ContentPlaceholderID="LeftColumn">
Content in the middle-level master
<asp:ContentPlaceholder runat="server" Id="LeftColumnSubContent" />
</asp:Content>