ContentPlaceHolderID can only refer to its immediate parent, if it is specified declaratively.
The simplest fix, though not the most elegant, is to copy the ContentPlaceHolders to the Nested Site.Master with the same default code. Some code duplication is required, but the job is in progress.
<%@ Master Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewMasterPage" %> <asp:Content ContentPlaceHolderID="TitleContent" runat="server"> <asp:ContentPlaceHolder ID="NestedTitleContent" runat="server"> <%= Html.GlobalModel().PageTitle %> </asp:ContentPlaceHolder> </asp:ContentPlaceHolder> <asp:Content ContentPlaceHolderID="SiteContent" runat="server"> <asp:ContentPlaceHolder ID="SiteContent" runat="server"> <h1>Nested Header</h1> <asp:ContentPlaceHolder ID="NestedContent" runat="server"/> </asp:ContentPlaceHolder> </asp:ContentPlaceHolder>
If you don’t want to do this, you can replace placeholders with custom controls that know what to show when.
Or, if you need to save it that way, you can run a bunch of code to force early rendering to a line / buffer in memory and replace child controls, but that will be a ton of problems, and it is doubtful if it will be worth the effort.
But any of these decisions depend on your situation. If you provided more context, we could provide more specific recommendations.
Jon adams
source share