1

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");

}
Myworld
  • 1,861
  • 16
  • 45
  • 75

3 Answers3

1
 CPCSS.Attributes.Add("class", "bag_d");
Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
1

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
  • 5,886
  • 1
  • 25
  • 41
0

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

This is probably a repeat of

How to edit CSS style of a div using C# in .NET

Community
  • 1
  • 1
Gordon Thompson
  • 4,764
  • 8
  • 48
  • 62