Two ContentPlaceHolders in the MasterPage

P

Peter Larsen [CPH]

Hi,

Are there a way to show both ContentPlaceHolser's at the same time ??
The following code show two ContentPlaceHolders, but i don't know what to do
to make them both visible at the same time.

<body>
<form id="form2" runat="server">
<div style="height:100px;">
Some text
</div>
<div style="position: relative; left: 250px; top: 150px; width:
400px; border-style: dotted;
border-color: Blue;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div style="position: fixed; left: 50px; top: 50px; width: 400px;
border-style: dotted;
border-color: Blue;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
<div>
Some more text
</div>
</form>
</body>

Thank you in advance.

BR
Peter
 
S

Stan

Hi,

Are there a way to show both ContentPlaceHolser's at the same time ??
The following code show two ContentPlaceHolders, but i don't know what todo
to make them both visible at the same time.

<body>
    <form id="form2" runat="server">
    <div style="height:100px;">
        Some text
    </div>
        <div style="position: relative; left: 250px; top: 150px; width:
400px; border-style: dotted;
            border-color: Blue;">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        <div style="position: fixed; left: 50px; top: 50px; width: 400px;
border-style: dotted;
            border-color: Blue;">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
            </asp:ContentPlaceHolder>
        </div>
    <div>
        Some more text
    </div>
    </form>
</body>

Thank you in advance.

BR
Peter

Hi Peter

You can have as many ContentPlaceHolders as you like and all can be
visible at the same time. The rules are as follows:

* If a ContentPlaceHolder is declared on the content page, it must
have a ContentPlaceHolderID property matching the ID property of one
of those declared in the master page. Otherwise an error is generated.

* Whatever is placed inside a valid ContentPlaceHolder on the content
page will be rendered in the normal way. If the corresponding
ContentPlaceholder on the master page has anything in it, then that is
overwritten by the content page version (including empty content).

* If a ContentPaceHolder declared on the master page has no matching
ContentPlaceHolder on the content page, then any content that exists
within that ContenPlaceHolder on the master page will be rendered on
the content page (i.e. becomes default content). If it is empty then
nothing will be rendered in that location.

Hope that makes sense
 
P

Peter Larsen [CPH]

Hi Stan,

Thanks for your input.

Yes it does make sense.
What you write is pretty much the same i have found. The problem is that i
don't see the content from the two ContentPlaceHolder's at the same time..
I have the following files:
Site.master
Default1.aspx
Default2.asps

If i select Default1.aspx and run the project, the content contained in
Default1 is shown and Default2.aspx is not shown. If i select Default2 and
run, the Default2 is shown and Default1 is hided.
I do see the div border read from the master file for both sections, its
just the content that is missing.

From what you say, both files should be visible, but that's not what i see
(?) !!
What am i doing wrong here ??

BR
Peter


On 26 Aug, 13:32, "Peter Larsen [CPH]" <[email protected]>
wrote:

* If a ContentPlaceHolder is declared on the content page, it must
have a ContentPlaceHolderID property matching the ID property of one
of those declared in the master page. Otherwise an error is generated.

* Whatever is placed inside a valid ContentPlaceHolder on the content
page will be rendered in the normal way. If the corresponding
ContentPlaceholder on the master page has anything in it, then that is
overwritten by the content page version (including empty content).

* If a ContentPaceHolder declared on the master page has no matching
ContentPlaceHolder on the content page, then any content that exists
within that ContenPlaceHolder on the master page will be rendered on
the content page (i.e. becomes default content). If it is empty then
nothing will be rendered in that location.

Hope that makes sense
 
J

Jialiang Ge [MSFT]

Hello Peter,

Stan meant to put the two content place holders in one aspx page. For
example:

Master page (MasterPage.master):

<body>
<form id="form1" runat="server">
<div>
This is:
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
<br />
And This is:
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>

Default.aspx page:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
ContentPlaceHolder1
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2"
Runat="Server">
ContentPlaceHolder2
</asp:Content>

Please try it again and let us know whether it helps you.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Larsen [CPH]

Hi Jialiang,

So what you say is that the content (ContentPalaceHolders) must come from
the same aspx file ??
I choose the aspx file to show - and thats what it does.

/Peter
 
S

Stan

Hi Jialiang,

So what you say is that the content (ContentPalaceHolders) must come from
the same aspx file ??
I choose the aspx file to show - and thats what it does.

/Peter

"Jialiang Ge [MSFT]" said:
Hello Peter,
Stan meant to put the two content place holders in one aspx page. For
example:

Hi Peter

Sorry for the delay in responding.

I'm not so sure now about what you are really asking.

If a client requests Default1.aspx then it will receive the result of
merging Site.master with Default1.aspx, according to the rules I
outlined previously. The content of Default2.aspx is not involved and
has no bearing on the result. Only the master and the requested
content page are used to service the request.
 
P

Peter Larsen [CPH]

Hi Stan,

Thanks for your comment - i understand now how it works.

/Peter
 

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

Top