[div ID="someDiv" runat="server"]
...
[/div]...
I stuck all the labels inside this div. Then, I did a foreach loop to grab all the controls.
foreach (Control ctrl in someDiv.Controls)
{
if (ctrl.GetType() == typeof(Label))
{
ctrl.Attributes.Add("onmouseover", "this.style.backgroundColor = 'Grey'");
ctrl.Attributes.Add("onmouseout", "this.style.backgroundColor="White"');
}
}
The one I did was _much_ more complicated than this because I had to highlight multiple labels at once with one mouseover (as well as deal with some weird variable names). Much deeper looping, but once you get it going, it is just finding the right way to loop through it. In my testing, this did _not_ work in Firefox. Since I don't get paid to work on it for Firefox, I won't delve too deep into it. Though Firefox supports pseudo-class hovering, so that isn't really a problem.
No comments:
Post a Comment