开发者

how can a MVC view to populate a contentplaceholder in not direct ancestor Master

开发者 https://www.devze.com 2023-04-04 18:25 出处:网络
i have a Master page and in it another Master and another Master. I want the view inside the third master to populate some contentPalceHolder in the upper-most Mas开发者_开发知识库ter.

i have a Master page and in it another Master and another Master. I want the view inside the third master to populate some contentPalceHolder in the upper-most Mas开发者_开发知识库ter.

How do I do it?


I used ContentPalceHolder and asp:Content to bubble the string from the inner aspx-view through all masters to the outer Master.

like this:

 <asp:Content ContentPlaceHolderID="headerText"  runat="server">
    <asp:ContentPlaceHolder ID="subTabsHeaderText" runat="server"></asp:ContentPlaceHolder>
</asp:Content>


You have to make that 'anscestor' trickle down through each Master page:

----BigBoss.Master----
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<Some.Type.Here>" MasterPageFile="~/Views/MasterPages/Site.Master" %>
<asp:ContentPlaceHolder id="cphTitle" runat="server"/>

----NotSoBigBoss.Master----
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<Some.Type.Here>" MasterPageFile="~/Views/MasterPages/BigBoss.Master" %>    
<asp:Content ContentPlaceHolderId="cphTitle" runat="server"/>

----ReallyLittleBoss.Master----
    <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<Some.Type.Here>" MasterPageFile="~/Views/MasterPages/NotSoBigBoss.Master" %>
<asp:Content ContentPlaceHolderId="cphTitle" runat="server">
    <!-- Stuff here -->
</asp:Content>
0

精彩评论

暂无评论...
验证码 换一张
取 消