开发者

How to set a CSSClass for a dynamically generated label?

开发者 https://www.devze.com 2022-12-30 19:14 出处:网络
How to set a CSSClass for a dynamically generated开发者_开发问答 label in asp.net with C# Label lbl = new 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

精彩评论

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

关注公众号