In my ASP.NET app I’m using AJAX and some web services to update an unknown number of instantiated user controls (hence the reason I’m using FindControl below).
When a function returns a result, I’m trying to change the color of a label control. This works:
$get("<%= me.FindControl("lblName").ClientID %>").style.color = 'red';
Now I would like to be able to specify the colors from a CSS file.
.MyRed
{
color:Maroon;
}
And here is the part I can’t figure out. I’ve tried using addClass and toggleClass but the browser reports “Object doesn’t support property or method ‘toggleClass'” etc.
$get("<%= me.FindControl("lblName").ClientID %>")...... = '.MyRed';
As always, thanks in advance!
Since you appear to be using the ASP.NET AJAX library, you can call Sys.UI.DomElement.addCssClass():