Tuesday, April 3, 2012

Dynamic css styles in asp.net

There are two different ways of applying css styles to asp controls .The customised css are easily control by .net.Here i will explain how to apply the css styles and The javascript functions like on mouseover and on mouse out are apply to hyperlink control dynamically.For this we have an property to add the attributes to server controls i:e "Attributes".
hrss.Attributes["style"] = "background: url(" + imgpath + ") no-repeat scroll 165px center #EEEEEE;display: inline-block;margin-left: 45px;margin-top: 10px;padding: 5px 20px 5px 0;text-align: right;width: 160px; color: #367C2B;";

hrss.Attributes["onmouseover"] = "this.style.color='#BB880B';this.style.background=' url(" + imagpathmouseover + ") no-repeat scroll 165px center #EEEEEE';";

hrss.Attributes["onmouseout"] = "this.style.color='#367C2B';this.style.background=' url(" + imgpath + ") no-repeat scroll 165px center #EEEEEE';";
Post a Comment

Bel