We help IT Professionals succeed at work.

.net nested master page wont display

dcmk
dcmk asked
on
Hi, i have the root.master page working it display, the first ContentPlaceHolder1 gets overridden.. by the contents from default.aspx.  The second placeholder doesnt get over-ridden by the second master page.. not having much luck with these.  here is from 'root.master'


<%@ Master Language="VB" CodeFile="root.master.vb" Inherits="MasterPage" AutoEventWireup="true" %>
..

<td colspan="5" valign="top" width="532" align="center"> <!--532-->
               
                          <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
                          </asp:ContentPlaceHolder>

....

...
..

<TD WIDTH='267'>
      <!-- OFFERS -->
       <asp:ContentPlaceHolder id="rhs1" runat="server">
       
       </asp:ContentPlaceHolder>
</TD>


this is rhs.master


<%@  Master Language="VB" MasterPageFile="~/root.master" AutoEventWireup="true" CodeFile="rhs.master.vb" Inherits="MasterPage2"  %>

<asp:Content ContentPlaceHolderID="rhs1" runat="server">

76768

   </asp:Content>


contents if it matters form default.aspx would be :

<%-- Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" --%>

<%@ Page MasterPageFile="~/root.master" src="cb_default.aspx.vb" Inherits="WebForm1" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="Form1" runat="server">
<asp:formview runat="server" id="f1">

   
                <ItemTemplate>
                <table border="1" bordercolor="#000000" bgcolor="#ffffff">  <!--Beginning of flash object-->
                   
                    <tr>
                           <td colspan="5" bgcolor="#000" style="color:#FC3; text-align:center; font-size:36px; ">
                                    <blink>Think Blink</blink>
                                </td>
                            </tr>
                   
                    <td width="50%" style="color:white; text-align:center; font-size:16px; ">ccdsfds
                        <asp:HyperLink  ID="link1" text=<%#  Container.DataItem("productName") & ":: £" & Container.DataItem("price") %> NavigateUrl=<%# "http://www.bath-depot.co.uk/productDetails.asp?prodID=" &  Container.DataItem("itemID") %> runat=server >
                        </asp:HyperLink > 
                    </td>
                      <td width="50%" style="color:#FC3; text-align:center; font-size:16px;">
                        <asp:HyperLink  ID="HyperLink1" text=<%# Container.DataItem("available") & " Available!" %> NavigateUrl=<%# "http://www.bath-depot.co.uk/productDetails.asp?prodID=" & Container.DataItem("itemID") %> runat=server >
                        </asp:HyperLink > 
                    </td>
                    </tr>
                    <td colspan='2'>
                    <asp:Image ID="image1" AlternateText="image1" ImageUrl=<%# "http://www.bath-depot.co.uk/" & Container.DataItem("image")  %> width="432" height="378"  runat=server />

                   
                    </td>

                    <tr>
                    <td colspan='2' style="color:#FC3; background:#000; font-size:20px; text-align:center;">
                     <script type="text/javascript" language="JavaScript">  
                                          TargetDate = "<%# "17/02/2011 " & Container.DataItem("targetTime") %>";
                                          BackColor = "#000";
                                          ForeColor = "#FC3";  
                                          CountActive = true;  
                                          CountStepper = -1;
                                          LeadingZero = true;  

                                          DisplayFormat = "<font color='white'> %%H%% </font>Hours,<font color='white'> %%M%% </font>Minutes, <font color='white'>%%S%% </font>Seconds left!";
                                          FinishMessage = "Offer Ended! Await next offer at 10am";
                              </script>
                   
                              <script type="text/javascript" language="JavaScript" src="../countdown.js"></script>
                    </td>
                    </tr>
                    </table>
                    </td>
               
                </ItemTemplate>

</asp:formview>
 </form>
  <tr><td colspan='5' width='100%'><img width='100' height='15' src='images/spacer.gif' /></td></tr>
            <tr>
                <td colspan="5" align="center">
                       <img src="images/Bland.jpg" width="506px">
                </td>  
                <!--/td>
            </tr-->

             <tr><td colspan='5' width='100%'><img width='100' height='15' src='images/spacer.gif' /></td></tr>        
            <tr><td colspan='5' width='100%'><img width='100' height='15' src='images/spacer.gif' /></td></tr>
            <tr>
            <td colspan="5" width="100%" align="center">
                  <!--div style="position:relative;top:-55px"-->                    
                          <img src="images/shoptag.jpg">
                 <!--/div-->
            </td>
            </tr>

</asp:Content>

 



Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2008

Commented:
If you have .NET 2005, it had a lot of problems with nested master pages in the designer.  The 2008 and 2010 can handle nested master pages correctly.  If you are really using 2.0, you might want to reevaluate the need for nested master pages.
When a master page is consumed, each contentplaceholder is customized or defaults to the master's content.  Since in your snippet the nested masterpage, (rhs.master), does not customize ContentPlaceHolder1, then it defaults to the root.master's content and is not available to the default.aspx page.

  try this snippet example to demonstrate what I think you want to do....

... root.master
<%@ Master Language="VB" CodeFile="root.master.vb" Inherits="root" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  <title>EE Problem</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <table>
      <tr>
        <td colspan="5" valign="top" width="532" align="center" bgcolor="#66FF99">
          <!--532-->
          <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            root ContentPlaceHolder1
          </asp:ContentPlaceHolder>
        </td>
      </tr>
      <tr>
        <td width="267" bgcolor="Yellow">
          <!-- OFFERS -->
          <asp:ContentPlaceHolder ID="rhs1" runat="server">
            root rhs1
          </asp:ContentPlaceHolder>
        </td>
        <td colspan="4" bgcolor="#3366FF">
          &nbsp;blank
        </td>
      </tr>
    </table>
  </div>
  </form>
</body>
</html>


.... rhs.master
<%@ Master Language="VB" MasterPageFile="~/root.master" AutoEventWireup="true" CodeFile="rhs.master.vb" Inherits="rhs" %>


<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">
  <asp:ContentPlaceHolder runat="server"  ID="ContentPlaceHolder1" >        
          rhs ContentPlaceHolder1
  </asp:ContentPlaceHolder>          
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="rhs1" Runat="Server">
  76768
</asp:Content>


...default.aspx

<%@ Page Title="" Language="VB" MasterPageFile="~/rhs.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">
        
       Info from detail
</asp:Content>

Open in new window