How to set CSSClass for dynamically created label?

How to set CSSClass for dynamically created label in asp.net using C #

+7
c #
source share
4 answers
Label lbl = new Label(); lbl.Text = "Hello World!"; lbl.CssClass = "red_and_bold"; 
+4
source share
0
source share

If you mean server-side configuration, you can use the WebControl.CssClass property:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass.aspx

0
source share

Label lblPrivacyGender = new Label (); lblPrivacyGender.Attributes.Add ("class", "spanHeaderStyle"); lblPrivacyGender.Text = "Gender:";

Above spanHeaderStyle is a CssClass that was previously defined

0
source share

All Articles