Change the URL for the background image programatically?

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?
 
M

Mark B

<% 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'; >"
 
A

Alexey Smirnov

 <%   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 .... "" ....
 
M

Mark B

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.
 
A

Alexey Smirnov

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
 

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