ASP.Net复选框缺少CSS类 [英] ASP.Net checkbox missing CSS class
问题描述
我有以下ASP.Net复选框控件添加到页面:
I have the following ASP.Net check box control added to a page:
< ASP:复选框ID =chkActive=服务器的CssClass =MyClass的/>
但是,当页面被渲染它忽略了CssClass属性的值:
But when the page gets rendered it ignores the value of the CssClass property:
<input name="ctl00$mainContent$chkActive" id="ctl00_mainContent_chkActive" type="checkbox" value="on"/>
任何想法如何的CSS类适用于ASP.Net复选框?
Any ideas how to apply the css class to the ASP.Net check box?
谢谢
阿兰。
推荐答案
好吧,当你申请一个的CssClass于ASP.Net复选框控制它的类适用于包装的复选框的跨度。由于CSS类是不能直接应用于元素而不会覆盖已经应用于所有输入elements.Therefore我用jQuery来选择元素,并应用必要的样式类。
Ok, when you apply a CssClass to the ASP.Net check box control it applies the class to a span that wraps the check box. Because the css class isn't applied directly to the element it doesn't override the class that has been applied to all input elements.Therefore I used jQuery to select the element and apply the necessary style.
$("input[type=checkbox]").addClass("myClass");
这篇关于ASP.Net复选框缺少CSS类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!