content page doesn't display from nested master pages

I have two master pages, one nested. The first one (cuw.master), of course, feeds into the second one (profile.master), which in turn I would expect to feed into the desired content page (reg.aspx). The profile.master, in design view, displays what I want to see on the content page; however, the content page displays only what's on the first master page (cuw.master). It's possible that I have the master base and master child confused, but it doesn't seem like it. I have another master page that I use successfully but this instance, with nested pages, has me befuddled. Please see code below and offer your suggestions. Thanks.

cuw.master:
--Contains a CreateUserWizard with a ContentPlaceHolder in the ContentTemplate of the CreateUserWizardStep. 
<asp:CreateUserWizardStep ID="cusReg" Title="Register" EnableViewState="False" runat="server">
    <ContentTemplate>
        <asp:ContentPlaceHolder ID="cphProfile" runat="server" />
    </ContentTemplate>
</asp:CreateUserWizardStep>
 

profile.master:
--CPH's in this master should feed into the content file but don't. The content that should result from this page I want to be reusable in other locations. 

<%@ Master Language="VB" MasterPageFile="~/masters/cuw.master" CodeFile="profile.master.vb" Inherits="masters_profile" %><asp:Content ID="cntProfile" ContentPlaceHolderID="cphProfile" runat="Server">
<table>
    <tr>
        <td colspan="3">
            <asp:ContentPlaceHolder ID="cphTop" runat="server" />
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <asp:ContentPlaceHolder ID="cphPhoto" runat="server" />
        </td>
    </tr>
    <tr>
        <td>
            <table>
                <tr>
                    <td>
                        <div class="left-container-cuw">
                        </div>
                        <div class="middle-container-cuw">
                            <asp:ContentPlaceHolder ID="cphLblFirstName" runat="server" />
                        </div>
                        <div class="right-container-cuw">
                            <asp:ContentPlaceHolder ID="cphFirstName" runat="server" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="mid-container-edit">
                            <asp:ContentPlaceHolder ID="cphRfvFirstName" runat="server" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="left-container-cuw">
                        </div>
                        <div class="middle-container-cuw">
                            <asp:ContentPlaceHolder ID="cphLblLastName" runat="server" />
                        </div>
                        <div class="right-container-cuw">
                            <asp:ContentPlaceHolder ID="cphLastName" runat="server" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="mid-container-edit">
                            <asp:ContentPlaceHolder ID="cphRfvLastName" runat="server" />
                        </div>
                    </td>
                </tr>
[snip]
</asp:Content
 
reg.aspx:
--content file
<%@ Page Title="Register with Your Class" Language="VB" MasterPageFile="~/masters/profile.master" AutoEventWireup="false" 
    CodeFile="reg.aspx.vb" Inherits="reg" %>
<%@ Register TagPrefix="photo" TagName="upload" src="~/userControls/photo.ascx" mce_src="~/userControls/photo.ascx" src="~/userControls/photo.ascx" mce_src="~/userControls/photo.ascx" src="~/userControls/photo.ascx" mce_src="~/userControls/photo.ascx" src="~/userControls/photo.ascx" mce_src="~/userControls/photo.ascx" %>
<%@ Register TagPrefix="prof" TagName="prof" src="~/userControls/prof.ascx" mce_src="~/userControls/prof.ascx" src="~/userControls/prof.ascx" mce_src="~/userControls/prof.ascx" src="~/userControls/prof.ascx" mce_src="~/userControls/prof.ascx" src="~/userControls/prof.ascx" mce_src="~/userControls/prof.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphTop" runat="Server">
    <prof:prof ID="top" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphPhoto" runat="Server">
    <photo:upload ID="photo" runat="server" />
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="cphLblFirstName" runat="Server">
    <asp:Label ID="lblFirstName" AssociatedControlID="txtFirstName" Font-Bold="True"
        Text="First Name:" runat="server" />
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="cphFirstName" runat="Server">
    <asp:TextBox ID="txtFirstName" TabIndex="5" Width="150px" runat="server" />
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="cphRfvFirstName" runat="Server">
    <asp:RequiredFieldValidator ID="rfvFirstName" ControlToValidate="txtFirstName" Display="Dynamic"
        ErrorMessage="First Name Required" Font-Bold="True" Font-Size="Smaller" SetFocusOnError="true"
        Text="*First Name Required" ToolTip="First Name Required" runat="server" />
</asp:Content>
<asp:Content ID="Content9" ContentPlaceHolderID="cphLblLastName" runat="Server">
    <asp:Label ID="lblLastName" AssociatedControlID="txtLastName" Font-Bold="True" Text="Last Name:"
        runat="server" />
</asp:Content>
<asp:Content ID="Content10" ContentPlaceHolderID="cphLastName" runat="Server">
    <asp:TextBox ID="txtLastName" TabIndex="10" runat="server" />
</asp:Content>
<asp:Content ID="Content11" ContentPlaceHolderID="cphRfvLastName" runat="Server">
    <asp:RequiredFieldValidator ID="rfvLastName" ControlToValidate="txtLastName" Display="Dynamic"
        ErrorMessage="*Last Name Required" Font-Bold="True" Font-Size="Smaller" SetFocusOnError="true"
        Text="*Last Name Required" ToolTip="Last Name Required" runat="server" />
</asp:Content>
0
muybn
2/1/2009 6:11:05 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

5 Replies
1150 Views

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

 Hi there,

Your explanation contradicts with the code you provided! You said that cuw.master feeds into profile.master, which indicates that profile.master is the parent. In the code, it is the opposite! So, which one is the Parent and which is the Child?

If I'm going to relay on code, then cuw is the Parent and profile is the Child (content page --> profile --> cuw). Consequently, content page needs to be chunked into Content blocks according to profile.master as demonstrated in the code. However, I don't see the opening tag of profile's asp:Content, which should reference the ID of cuw's ContentPlaceHolder. Child masters need to follow same approach as content pages in terms of implementing asp:Content blocks.

Aside form that, I don't see a problem. If you attempt to view content page in Designer, then obviously it will be displayed as part of the Parent master, exactly as it would show when loaded, hence, the loading of Parent master by the Designer. You can't view the page in Child master if this is what you are up to, nor you can even view the Child master independently.

Hope this helps.

Regards,


Saed Hamdan
"Man could be destroyed but not defeated." --Hemmingway
0
saedh
2/2/2009 4:07:03 AM

Thanks for your help, Saed. For brevity's sake, I initially had to pick and choose which code to use. Following is the actual beginning and end of profile.master. Please let me know if this is what you're referring to or not in your advice.

By the way, I commend your excellent command of English. Oman has an interesting past and present. My cousin and his wife have lived in Doha the last few years and really enjoy it. They work for a joint project between an U.S. university and something to do with a family life project sponsored by the government of Qatar.

<%@ Master Language="VB" MasterPageFile="~/masters/cuw.master" CodeFile="profile.master.vb" Inherits="masters_profile" %>

<%@ Register TagPrefix="photo" TagName="upload" src="~/userControls/photo.ascx" mce_src="~/userControls/photo.ascx" %>
<%@ Register TagPrefix="prof" TagName="prof" src="~/userControls/prof.ascx" mce_src="~/userControls/prof.ascx" %>
<%@ Register Namespace="Util" TagPrefix="util" %>
<%@ Register Namespace="customControls" TagPrefix="custom" %>

<asp:Content ID="cntProfile" ContentPlaceHolderID="cphProfile" runat="Server">
    <table>
        <tr>
            <td colspan="3">
                <asp:ContentPlaceHolder ID="cphTop" runat="server" />
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:ContentPlaceHolder ID="cphPhoto" runat="server" />
            </td>
        </tr>
 [snip] 
            </td>
        </tr>
    </table>

</asp:Content
0
muybn
2/2/2009 6:12:56 AM

Glad to see someone is aware of this side of the pondSmile

Your code sounds fine my friend, so where is the problem? As I said, you can't view your content page through the profile master in Designer since it is not the top level master. This is the default behaviour (and logical IMHO). Neither declaration nor coding can change that.

I too use two levels of masters. But before embarking on that and split the declaration between, I built a single aspx page where I setup entire layout for testing. When page displays as desired, I commenced the 'house keeping' and divided the layout accordingly, injecting required asp:Content blocks as deemed necessary in both masters.

Good luck.

Regards,


Saed Hamdan
"Man could be destroyed but not defeated." --Hemmingway
0
saedh
2/3/2009 7:42:37 AM
I thought I had the right idea but I keep going back and forth on what to include and where. Following is what I have presently and what I need; let's see if these ideas will help clarify what I'm trying to do and get me more guidance from the gurus of nested master pages.

Present:
CreateUserWizard which contains the templated steps CreateUserWizardStep and CompleteWizardStep. Currently within the CreateUserWizardStep's ContentTemplate are markup and controls for people to register on the site. I also need to include this content in about four other pages, sometimes in slightly different format for either display or editing, depending on the particular content; so I need this content in a separate master page. Thus, I've been laboring with nested master pages, user controls, and combinations of these two concepts, without success.

Needed:
A coherent way of reusing the material presently contained in the CreateUserWizardStep's ContentTemplate. My dilemma is that in my present mode of thinking, the CreateUserWizard will be cut in half with the ContentPlaceHolder (before and after the ContentTemplate location--which I in fact tried and received errors that the beginning and ending tags of the wizard were missing). This diagram shows more or less a pictorial:

parent master page:
<ContentPlaceHolder />
<asp:Panel ID="pnlFirstName" Visible="true" runat="server">
    <tr>
        <td>
            <div class="left-container-cuw">
            </div>
            <div class="middle-container-cuw">
                <asp:Label ID="lblFirstName" AssociatedControlID="txtFirstName" Font-Bold="True"
                    Text="First Name:" runat="server" />
            </div>
            <div class="right-container-cuw">
                <asp:TextBox ID="txtFirstName" TabIndex="5" Width="150px" runat="server" />
            </div>
        </td>
    </tr>
</asp:Panel>
<asp:Panel ID="pnlLastName" Visible="true" runat="server">
    <tr>
        <td>
            <div class="left-container-cuw">
            </div>
            <div class="middle-container-cuw">
                <asp:Label ID="lblLastName" AssociatedControlID="txtLastName" Font-Bold="True" Text="Last Name:"
                    runat="server" />
            </div>
            <div class="right-container-cuw">
                <asp:TextBox ID="txtLastName" TabIndex="10" runat="server" />
            </div>
        </td>
    </tr>
</asp:Panel>
<ContentPlaceHolder />
+
child master page:
<Content>            top of CreateUserWizard (including ContentTemplate; see below)<Content>
master page content (see below)
<Content>            bottom of CreateUserWizard (see below)<Content>
=
hoped-for content page:
<CreateUserWizard>
<CreateUserWizardStep>
<ContentTemplate>
parent master content
</ContentTemplate>
</CreateUserWizardStep>
</CreateUserWizard>

Again, my question is, how do I get around the wizard's ContentTemplate tags?
0
muybn
2/6/2009 2:59:32 AM

Hmm, no replies; maybe I didn't explain my problem clearly enough. All I know is that for every alteration I make in my layout, I have to copy and paste it once again in all four file locations, which is getting very tedious. I would, of course, much rather be able to make one alteration and have it propagate to the various pages. I know that there's an answer to what I'm doing but I can't quite put my finger on it. I guess I could make a master page for each content page that I want to produce but that too would seem terribly inefficient. Unless I'm seeing the whole matter backwards, the typical master page schema is:

Master content 1
ContentPlaceHolder
Master content 2

In my case, assuming I'm seeing everything correctly, I need:

ContentPlaceHolder1
Master content
ContentPlaceHolder2

But, as described in my previous post, this isn't possible since the two content placeholders would have to come into the content page as the first half and second half of the CreateUserWizard, which doesn't work since the wizard doesn't expect to be split in half in the middle of a wizard step.

Did I clarify my dilemma any? Need some help on this, please.

0
muybn
2/7/2009 9:43:13 AM
Reply:

Web resources about - content page doesn't display from nested master pages - asp.net.navigation-controls

Resources last updated: 11/23/2015 7:20:47 PM