asp.net - Accessing Grandparent Content Placeholder in Master Pages -
I'm searching the web and I'm not looking for any answers (there were some questions added on the stack overflow, but They 'I think I have to answer or be the same), so I thought I wanted to be one of my own. It revolves around nested master pages and a content page, which reaches the grandparents' content place holder, even if this parent has not been exposed again in the nested master . I am thinking that this is not possible.
Core Site Master Nested Site. Master (Note how title content and head content were not optimized, so the 'default' content from the core site should affect the master.) ContentView.aspx (referring to the nested site. The title content replacement attempt will not work.) The easiest fix, even if not the most elegant, is that the content with the default code is called Nested Site. Mister . Some code repeats are required, but the work is completed. If you do not want to do this, you can replace placeholders with custom controls that know when to show up. Or, if you need to keep it this way, you can run an in-memory string / buffer code for initial rendering, and change the hair control with it? But this will be a ton of troubles, and it is doubtful if it is worth the effort. But none of those solutions depends on your situation. If you provide more context, then we can provide more specific advice.
& lt; Html xmlns = "http: // www. W3.org/1999/xhtml"> & Lt; Head runat = "server" & gt; & Lt; Title & gt; & Lt; Asp: ContentPlaceHolder ID = "Title Content" Run = "Server" & gt; & Lt;% = Html.GlobalModel () PageTitle% & gt; & Lt; / ASP: ContentPlaceHolder & gt; & Lt; / Title & gt; & Lt; Asp: ContentPlaceHolder id = "head content" run = "server" & gt; & Lt; Link rel = "shortcut icon" href = "<% = ViewContext.ClientContent (" Content / Tiki.ico ")% & gt;" Type = "image / x icon" /> & Lt; / ASP: ContentPlaceHolder & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Asp: ContentPlaceHolder id = "SiteContent" runat = "server" /> & Lt; / Body & gt; & Lt; / Html & gt;
& lt;% @ Master language = "c #" masterpagefile = "~ / view / share / site.masterer" inheritance = "system.web.mvc.vnuvers page"% & gt; & Lt; ASP: Content Content PlaceholderID = "Site Content" Runat = "Server" & gt; & Lt; Asp: ContentPlaceHolder id = "SiteContent" runat = "server" & gt; & Lt; H1 & gt; Nested Header & lt; / H1> & Lt; Asp: ContentPlaceHolder id = "Nested content" run = "server" /> & Lt; / ASP: ContentPlaceHolder & gt; & Lt; / ASP: ContentPlaceHolder & gt;
& lt;% @page language = "c #" masterpagefile = "site.master"% & gt; & Lt; ASP: Content Content PlaceholderID = "Nested Content" Runat = "Server" & gt; & Lt; P & gt; Nested material will do this work. & Lt; / P & gt; & Lt; / ASP: Content & gt; & Lt; ASP: Content Content PlaceholderID = "Title Content" Runat = "Server" & gt; Nested Title This ** ** Will Not Work & Lt; / ASP: Content & gt; ContentPlaceHolderIDs can only be listed when referring to your immediate guardian.
& lt;% @ master language = "c #" masterpagefile = "~ / view / share / site.masters" inheritance = "system web.mvcViewMasterPage"%> & Lt; ASP: Content Content PlaceholderID = "Title Content" Runat = "Server" & gt; & Lt; Asp: ContentPlaceHolder ID = "NestedTitleContent" runat = "server" & gt; & Lt;% = Html.GlobalModel () PageTitle% & gt; & Lt; / ASP: ContentPlaceHolder & gt; & Lt; / ASP: ContentPlaceHolder & gt; & Lt; ASP: Content Content PlaceholderID = "Site Content" Runat = "Server" & gt; & Lt; Asp: ContentPlaceHolder id = "SiteContent" runat = "server" & gt; & Lt; H1 & gt; Nested Header & lt; / H1> & Lt; Asp: ContentPlaceHolder id = "Nested content" run = "server" /> & Lt; / ASP: ContentPlaceHolder & gt; & Lt; / ASP: ContentPlaceHolder & gt;
Comments
Post a Comment