468,309 Members | 1,095 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,309 developers. It's quick & easy.

Masterpage ContentPlaceHolder within quotes?

I would like to use a ContentPlaceHolder within the following. Any ideas on
how to best accomplish this?
<td rowspan="2" style="width: 600px; background-image:
url('<asp:ContentPlaceHolder ID="ContentPlaceHolderRight" runat="server"
/>'); background-position: bottom right; background-repeat: no-repeat;">

I am thinking that I might have to use a set method off of the masterpage to
set this but I would rather do it declaratively in my content page.

Thanks,

--
Andrew Robinson
http://blog.binaryocean.com

Jun 3 '06 #1
2 1692
I'm having problems of my own with loading content into a ContentPlaceHolder
that is the child of a Panel control. For your problem I would try it this
way...

<td>
<asp:ContentPlaceHolder ID="GenerateImagePlaceHolder" ... />
</td>

Generate your image using application logic in a content page using the
ContentPlaceHolderID.
<!-- HTML from content page -->
<asp:Content ID="GeneratedImage"
ContentPlaceHolderID="GenerateImagePlaceHolder" ...>
<asp:Image ID="ImageGenerated" .... />
</asp:Content>
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
I would like to use a ContentPlaceHolder within the following. Any ideas on
how to best accomplish this?
<td rowspan="2" style="width: 600px; background-image:
url('<asp:ContentPlaceHolder ID="ContentPlaceHolderRight" runat="server"
/>'); background-position: bottom right; background-repeat: no-repeat;">

I am thinking that I might have to use a set method off of the masterpage
to set this but I would rather do it declaratively in my content page.

Thanks,

--
Andrew Robinson
http://blog.binaryocean.com

Jun 4 '06 #2
Hi Andrew,

Thank you for your post!

Based on my understanding, your questions are as follows:
1) Is it possible to declare a server control in quotes?
2) How to change a background image url on the Master Page from a Content
Page?
If there's anything I've misunderstood, please feel free to post here.

The answer to the first question is No. The "<td" element is client-side,
and only directives such as "<%" or "<%=" are allowed to be included in
quotes.

As for the 2nd question, I think it's more appropriate to define a public
property in the Master Page and set it in the Content Page. For example:

1) Define a public property in the Master Page:

private string _backgroundImageUrl;

public string BackgroundImageUrl
{
get { return _backgroundImageUrl; }
set { _backgroundImageUrl = value; }
}

2) Reference the property in its HTML source:

<table><tr><td
style="background-image:'<%=BackgroundImageUrl%>'"></td></tr></table>

3) In the Content Page's declaration, reference to the Master Page type:

<%@ MasterType VirtualPath="~/MasterPage.master" %>

This will enable strong type reference in the code-behind class of Content
Page.

4) Set the Master Page's property in the Content Page:

protected void Page_Load(object sender, EventArgs e)
{
Master.BackgroundImageUrl = "test1.gif";
}

Hope this helps. If anything is unclear, please feel free to post here.
Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Adam Tibi | last post: by
3 posts views Thread by MRW | last post: by
6 posts views Thread by =?Utf-8?B?QmVuIFIu?= | last post: by
3 posts views Thread by Tor Inge Rislaa | last post: by
6 posts views Thread by Peter Larsen [CPH] | last post: by
reply views Thread by Tommy Jakobsen | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.