Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attribues.Add()

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
0
0
US
I want to change the color of the form if a particular label is visible.

lblGo.Attributes.Add("onload", "color();") 'doesn't Work

lblGo.Attributes.Add("onclick", "color();") 'works but doesn't serve my purpose

<script language=&quot;javascript&quot;>
<!--
function color()
{document.bgColor = &quot;#99cc99&quot;;
}
//-->
</script>

Is there some other way of doing this?

Thanks in advance.
 
You don't need to use script. In your code behind can you check the visible property of the label and set the colour of the HTMLForm there.

NB: The HTML Form is a child of the Page object so I think...
Code:
if (Label1.Visible)
{
page.HTMLForm.Backcolor = System.Drawing.Colour.Yellow
}
else
{
page.HTMLForm.Backcolor = System.Drawing.Colour.White
}
...the property may not be Backcolor, but I'm away from my development PC and can't check, apologies.

Rhys

Be careful that the light at the end of the tunnel isn't a train coming the other way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top