tags:

views:

63

answers:

3

I had controls any control have class from style sheet when I click on event .I tried to do that but i didnot please any one help me.

aspx:

 <a  id="CPCSS" runat="server" href="CompanyProfile.aspx" >Company Profile</a>

CEO Word

cs:

  protected void CPCSS_onclick(object sender, EventArgs e)
{
    CPCSS.Attributes.Add("Class", "ad_mun_font_r");
    CEOCSS.Attributes.Add("Class", "ad_mun_font");
}
protected void CEOCSS_onclick(object sender, EventArgs e)
{
    CEOCSS.Attributes.Add("Class", "ad_mun_font_r");
    CPCSS.Attributes.Add("Class", "ad_mun_font");

}
A: 

CPCSS.Attributes["class"] = "bag_d";

This is probably a repeat of

http://stackoverflow.com/questions/175381/how-to-edit-css-style-of-a-div-using-c-in-net

Gordon Carpenter-Thompson
+1  A: 
 CPCSS.Attributes.Add("class", "bag_d");
Claudio Redi
+1  A: 

Use

CPCSS.Attributes.Add("class", "bag_d");

Or use HyperLink control (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.aspx, property CssClass) instead of raw anchor element.

Tomas Voracek