Hi Adam,
Using ASP is one way to do it, but there is a client side / JavaScript / DHTML solution as well. Instead of trying to get at the image directly, try to get at its parent. The background image is really a property of the table cell you're trying to change. So, you can use JavaScript to get a reference to the <td> element, and then use its CSS style.backgroundImage (note that CSS uses background-image) to change the image. Below you'll find a working example; copy it to a new document and then just click the button to see the image change:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Change Background</title>
<script type="text/javascript">
function ChangeBackground()
{
document.getElementById('myTableCell').style.backgroundImage =
'URL(/Images/Image2.gif)';
}
</script>
</head>
<body>
<table width="200" border="0">
<tr>
<td id="myTableCell" background="/Images/Image1.gif">
I am a cell with a background image<br />
<br />
If you click the button, my background will change.
</td>
</tr>
</table>
<form id="frmTest" name="frmTest" action="" method="get">
<input type="button" id="btnDo"
name="btnDo" onclick="ChangeBackground()"
value="Click to change Backgound" />
</form>
</body>
</html>
If you go this route, you should also change the deprecated background property of the <td> element to newer css style="background-image=..." syntax.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to:
Dissolved Girl by
Massive Attack (Track 6 from the album:
Mezzanine)
What's This?