Masterpage ContentPlaceHolder within quotes?

  • Thread starter Andrew Robinson
  • Start date
A

Andrew Robinson

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,
 
C

clintonG

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/
 
W

Walter Wang [MSFT]

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.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top