如何在运行时将CSS类添加到标签 [英] How to add css class to label at runtime

查看:59
本文介绍了如何在运行时将CSS类添加到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用ASP.NET(4.0).在我的应用程序中,我在运行时创建了一些标签.
我有一个css文件,在该文件中,我有一个名为"dy"的类.
我尝试了以下代码:

Hi,

I am working on ASP.NET(4.0). In my application I have created some label at runtime.
I have one css file, in that file I have one class called "dy".
I have tried following code:

lbl.cssclass="dy"


其中lbl是我的动态标签对象,但不起作用.

请帮帮我.


where lbl is my dynamic label object, but it is not working.

Please help me out.

推荐答案

Label lblNew = new Label();
lblNew.CssClass = "CssClass1";


您是否在页面中引用了样式表(还检查了该样式表中是否存在 dy 类)?

仅供参考 WebControl.CssClass属性 [ ^ ]


Did you refer the stylesheet(Also check if the class dy exists in this stylesheet) in your page?

FYI WebControl.CssClass Property[^]


这篇关于如何在运行时将CSS类添加到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆