Programmatically set a content pages Master page to another Master page which is nested in the original

Hello,

I have a set up where I have a main masterpage that I use most of the time but occasionally I need to swtch to another masterpage which is actually nested to the main masterpage. The switch needs to happen between postbacks from one content page to another. The problem I'm having, is that it is giving me an exception that it cannot find the content place holders in in the main master page.

I have overriden the OnPreInit event of the content page where I check a session variable to see if I need to load the nested page or the main page. When I try to load the page I am presented with the exception.

Here is the exception ... "Cannot find ContentPlaceHolder 'head' in the master page '/Masterpages/WizardMaster.Master', verify content control's ContentPlaceHolderID attribute in the content page. "

 Has anyone else run into this before?


Here are your options, Good, Cheap and Fast. Pick any two...
0
williamkmanire
12/10/2008 1:43:20 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

3 Replies
2393 Views

Similar Articles

[PageSpeed] 52

Hello There,

can i ask you how you are finding the ContentPlaceHolder "head" from the contentpage.

Thanks

 


Keyboard not found. Please Press < F1 > to RESUME

Please Remember to Mark as Answer for the post(s) that help you.....so it can help others......Thanks
0
novicehere
12/10/2008 3:07:24 AM

 

novicehere:

Hello There,

can i ask you how you are finding the ContentPlaceHolder "head" from the contentpage.

Thanks

 

That task is being performed by the content page I believe. I am not directly making the call for the head ContentPlaceHolder.

-----EDIT-----

 I was able to resolve the problem by nesting another head contentPlaceHolder inside of a content control. So the main master page has this :

<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>

And the nested master page has this :

<asp:Content ID="HeadContent" ContentPlaceHolderID="head" runat="server">
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>

 

Thank you for having a look into this for me.


Here are your options, Good, Cheap and Fast. Pick any two...
0
williamkmanire
12/10/2008 6:18:39 PM

this one actually helped me. thank you.

0
vijeya
5/1/2009 4:17:06 PM
Reply:

Similar Artilces:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

synchronizing content pages to master page when master page is edited
 Hi Guys,I'm new to designing websites so please forgive this basic question.I've updated my master page and the modfications ( adding a couple of extra place holders)  are not reflecting in the content pages.Is there any way we can update the content pages created before the changes to the master page were made.Thanks a lot  :)  abhinaynag: I'm new to designing websites so please forgive this basic question. I've updated my master page and the modfications ( adding a couple of extra place holders)  are not reflecting in the content pages. Is t...

Having Problem in Posting Value from a Content Page to another Content Page within a Same Master Page
Hello, I have a Master Page which contains two Content pages named: Default.aspx and Default2.aspx. I want to post a TextBox1 value (in Default.aspx) to Default2.aspx in the Master Pages and all my pages are in ContentPlaceHolder, but it is not working.   Is there Any kind of help?  Hi,you can pass value between two web forms by Query string, session  or by using cookieFor query string  refer : http://www.codeproject.com/KB/aspnet/QueryString.aspxSession: save session in default.aspx Session("t1")=text1.text retrieve session astext2.text = session(&quo...

Master page and nested master page
Hi GuysYou have probably heard this question before. I sit and try to create a Master Page with nested Master Page in That I had intended is this: I have a Master Page (globalMaster.Master) which contain the Header and Footer. In the Master Page I have a nested master of the left menu (leftColumnNav.master) and right menu (RightColumnNav.master) In addition, I have Content Placeholder for my content. My problem is that I neither get my left or right menus to show. While the text in the middle (content) is showing fine. I lists the code (yes is f. ..... long) What do I do wrong and is ...

Change content pages of Master Page without Master Page posting back?
so Master + content pages seems like exactly what I want except that they are assembled on postbacks. I am trying to make a site where both Master and Content pages have updatepanels, and the site switches content pages (40+ content pages) without the master page refreshing. Master Pages are assembled on postbacks so I don't think simple master page will work without annoying postbacks. I tried an approach where load content pages inside an Iframe, but the content pages take too long to load becuase each content page loads its own scriptmanager. View/Multiview will probably work but dif...

Value of the control at Master page is not being set from the content page
I am trying to set the value of the control at Master Page from the child page(content page) but the value of the control at master page is not changing.."Hope its your Solution so Mark it as Answer"Ahmad SheikhMicrosoft Valuable Geekhttp://sharpcontents.blogspot.com Here is a good tutorial on doing this from scott. http://www.odetocode.com/Articles/450.aspx here is the part you are looking for I think. Protected Sub Page_Load(ByVal sender As Object, _                     &...

Displaying the content of master page on a web inherited from nested master page
Hello! is it possible to display the content of general master page (common footer) on a web page, inherited from nested master page? Here is my code:Main master: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="1.master.cs" Inherits="_1" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"></head><body> <asp:ContentPlaceHolder ID="generalBody" runat="server"...

HELP..... Master Page Error (The page has controls that require a Master Page, but none is specified.)
Hi, I had almost finished creting my master page to use as a template for all future internal applications.  I had created a template to use in creatign new applications and had sucessfully created a new project based upon the MasterPage template... All was working well when I noticed a small graphic inconsistancy on the MasterPage... I reopened the MasterPage and I got teh above error message... I have looked at the HTML and everything seems to be okay and there including the header lines... <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits=&qu...

Master Page
I am using a master page for a website (Vs 2008) . I am facing two problems - 1. In the Login page, I am hiding the logout hyperlink. After the user logs in successfully , I'm setting the visibility of the logout hyperlink to true. But then, when I navigate to another page, the logout button disappears -  forcing me to redo setting the visibility in every page. 2. I have a similar problem with an Image in the page too. When I change the image in the content page after login, it reverts back to the existing image in the master page ( this I guess is because the master page loads...

Show content in both Master Page ContentPlaceholder AND Content Page Content control
I note that by default or rendering rules, when you add content/controls to the Content Page ASP:Content control matched to a Master Page ContentPlaceholder, any content/controls in the matching Master Page ContentPlaceholder is not displayed. Is there a setting that can be made to merge or show both content/controls in the Master Page ContentPlaceholder and content/controls in the matching Content Page Content control? Thanks         Don't think so. If you specify a content control in your page then whatever is in there displays and anything in the...

Dynamic Nested Master Page in a Master Page
 Hi,What I'm trying to do is create a single web form, lets say "Default.aspx" which is based on a master page "Main.master". Till now all ok.Next I want to create several "versions" for a nester master page which will be changed inside the main Master Page according to the QueryString. Let's say if the Querystring is "id=6" then use nested page #5 and if it's "id=100" then use page #6. Of couse when I change the nested master page, all the internal content holders should change and I need to have programmatic access to them ...

Doing Postback from master page to page in master's content place holder(search page)
Hi, Currently I am trying to do a postback which returns results. The master page has a textfield and button and the button redirects to the search page.The search page also has a textfield and button and when the button is clicked, the query statements take the input from teh user and looks for results. Currently, A Crosspage postback of master page + other pages in content place holder ------> master page+search page in content place holder works.I am trying to do a postback which returns results in master page+search page which gets its input from the textbox of the master page ...

Web resources about - Programmatically set a content pages Master page to another Master page which is nested in the original - asp.net.navigation-controls

[...] How to Programmatically Administer Off-Facebook Pages with the Open Graph API - Inside Facebook ...
With the Open Graph protocol that Facebook announced at last week’s f8 conference, any URL can now be treated just like a Facebook Page. After ...

Well, This Is Different Time Inc. Now Selling Print Ads Programmatically
Machines are now selling some print ads at Time Inc. The nation's largest magazine publisher owner of People, Time, Sports Illustrated and InStyle ...

Now Marketers Can Buy Sponsored Content Programmatically
Publishers' branded content is going programmatic. Today, Sharethrough and AppNexus are rolling out real-time bidding for Sharethrough's news ...

Wesabe makes Financial Data available programmatically
Wesabe has just done what I've been trying to convince banks to do for years. They're making financial data available via a simple POX (Plain ...

IPG Begins Buying Local Broadcast Programmatically: Can Target, Retarget Viewers In Near Real-Time
In what likely is the most significant development yet to bring programmatic media-buying to local broadcast television, Interpublic's Mediabrands ...

Google Launches Cloud SQL API To Allow Developers To Manage Their Databases Programmatically
... to use Google’s admin interface. Today, however, Google is launching the Cloud SQL API . This new REST API will allow developers to programmatically ...

Are Programmatically Purchased Native Ads Native Enough?
It seems everyone and their mothers are pushing native ad units and tools to support them. Facebook, Twitter, Yahoo and most recently AOL all ...

Most Major U.S. Publishers Now Sell Ads Programmatically
Most major online publishers in the U.S. now sell at least some of their ad space using automated "programmatic" technology, according to new ...

TV Ads Could Soon Be Sold Programmatically, Magna’s Todd Gordon
The key efficiency new-wave digital media sales holds over TV is clear – super-targeting through addressable, automated and programmatic buying ...

How To Use Facebook's New Power Editor For Ads
Here's a guide to the power editor in Facebook's ad manager.

Resources last updated: 1/9/2016 5:58:14 PM