color of one <td> change by program when load - how?

D

Dmitry N.Ananyev

Hello friends!

I am start my first ASP practic in VS2005.

**** My table ******************************
<table>
<tr>
<td></td>
</tr>
<tr>
<td style="background-color: #ccff66 ">TestColor</td>
</tr>
<tr>
<td></td>
</tr>
</table>

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

???
End Sub

*********************************************

How can I change color of one <td>TestColor</td> into other (random
different) when page load?

Please help me to start :)
 
M

MW de Jager

First you need to create an ID for your <td>
say <td id="tdTopCenter">TestColor</td>

create on onload event for your page
say <body onload="OnLoadEvent()">

Now create a method for the OnLoadEvent() and place it in the html header of
your page
<html>
....
<head>
....
<SCRIPT language="JavaScript">
function OnLoadEvent()
{
tdTopCenter.bgColor = TableCellColor.Value;
...
...
}
...
...
</SCRIPT>
....
</head>

You will need a hidden html server component "TableCellColor" on your aspx
page, which you can modify on the server side.
I think this should work, but you will have to test it yourself.

I hope this helps

MW
 

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