开发者

How to set a CSSClass for a dynamically generated label?

How to set a CSSClass for a dynamically generated开发者_开发问答 label in asp.net with C#


Label lbl = new Label();
lbl.Text = "Hello World!";
lbl.CssClass = "red_and_bold";


When You create Label then set its CssClass property:

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


If you mean setting it server-side you can use WebControl.CssClass property:

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


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

Above spanHeaderStyle is a CssClass which is previously defined

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜