Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

Are there nested master pages in ASP.NET MVC?

I wanted to know if the MVC framework can leverage the Nested Master Page? If so does anyone have some info on how to achive this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

We use nested master pages frequently, in order to seperate layout from standard includes and site wide markup, like so:

Site.Master:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage<PageViewModel>" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="language" content="en">
    <title><asp:ContentPlaceHolder ID="Title" runat="server"><%= Model.Page.Title %></asp:ContentPlaceHolder></title>

    <% Html.RenderPartial("Head"); %>

    <meta name="robots" content="index, follow">
    <meta name="robots" content="noodp">
    <asp:ContentPlaceHolder ID="ExtraHead" runat="server"></asp:ContentPlaceHolder>
</head>
<body >

    <asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>

</body>
</html>

then have a another master using the Site.Master,

Standard.Master:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage<PageViewModel>" MasterPageFile="Site.Master" %>
<asp:Content ContentPlaceHolderID="ExtraHead" runat="server">
    <asp:ContentPlaceHolder ID="ExtraHead" runat="server"></asp:ContentPlaceHolder>
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">


            <asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>


</asp:Content>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...