Content Controls Problem in ASP.NET 2.0

A

Adam Tibi

Hello,

I have this:

MasterPage 1:
<asp:ContentPlaceHolder ID="cphHead" runat="server">
</asp:ContentPlaceHolder>
Some Html...
<asp:ContentPlaceHolder ID="cphBody1" runat="server">
</asp:ContentPlaceHolder>

MasterPage 2:
<asp:ContentPlaceHolder ID="cphHead" runat="server">
</asp:ContentPlaceHolder>
Some Html...
<asp:ContentPlaceHolder ID="cphBody2" runat="server">
</asp:ContentPlaceHolder>

Page:
<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cphBody1" runat="Server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="cphBody2" runat="Server">
</asp:Content>


I need to load different MasterPage based on some factors, when I try to
load MasterPage 1, I get that the page "Content3" control points to an
invalid ContentPlaceHolderID. This error is logical and expected, however,
how can I turn this behaviour so that I don't want to show "Content3" in
case the MasterPage doesn't contain a ContentPlaceHolder for it.

I tried, in the page events, to detect the Content controls and eliminate
those that do not have a ContentPlaceHolder in the masterpage, but I failed
to detect the Content controls and I knew why when I've read:
http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx
Because the Content controls do not belong to the page!

Please if you have any solution or ideas for this, then hit me with it!

Thank you in advance,
Adam Tibi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top