Change the URL for the background image programatically?

  • Thread starter Thread starter Mark B
  • Start date Start date
M

Mark B

<table id='TopTable' style= "height: 176px; background-image:
url('../master_page/images/header_background.png'); width: 949px;"
width='949'; >


How would I change the URL for the background image programmatically?
 
<% Response.Write(fSetHeader()) %>


In vb code-behind:

fSetHeader = "<table id='TopTable' style=" + Chr(34) + "height: 176px;
background-image: url('../master_page/images/headers/" + fPictureName + "');
width: 949px;" + Chr(34) + " width='949'; >"
 
 <%   Response.Write(fSetHeader())                            %>

In vb code-behind:

 fSetHeader = "<table id='TopTable' style=" + Chr(34) + "height: 176px;
background-image: url('../master_page/images/headers/" + fPictureName + "');
width: 949px;" + Chr(34) + " width='949'; >"

...." + Chr(34) + "....

can be replaced by double quotes .... "" ....
 
Yeah I had that 'feeling' -- I suppose I could put an ASP.NET table in there
instead.

I see that an ASP.NET table control has a native background image property
which I assume translates into a background-image: style attribute.
 
Yeah I had that 'feeling' -- I suppose I could put an ASP.NET table in there
instead.

I see that an ASP.NET table control has a native background image property
which I assume translates into a background-image: style attribute.

Try to avoid this type of ASP Classic coding in ASP.NET at all costs,
especially Response.Write of HTML markup...
If you need to modify an element in code, add runat="server" to its tag so
that you have access to it server-side or, even better, use a webcontrol.

If you prefer to do this using CSS, you can consider to look at
ASP.NET Themes or Skins. Setting a theme applies styles and skins to
a page and controls. You can apply themes to a page, or a website.

ASP.NET Themes and Skins Overview
http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx
 
Back
Top