Below sample code shows how to alter the CSS at runtime,I have placed the label inside div and added runat
attribute.In page load,I have assigned the CSS name to div.
<div>
<asp:Button ID = "Button1" runat = "server" OnClick = "Button1_Click" Text = "Button" />
<div id = "divName" runat = "server">
<asp:Label ID = "Label1" runat = "server" Text = "Name: "></asp:Label>
</div>
</div>
.lblStyle
{
text-decoration:none;
font-weight: bold;
font-size:12px;
color:#007ddd;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
divName.Attributes["class"] = "lblStyle";
}
}