简体   繁体   English

在C#中将css类设置为HtmlInputCheckBox

[英]Setting a css class to HtmlInputCheckBox in C#

I am creating an HtmlInputCheckBox in C# and I am trying to set a css for it, but I cannot. 我在C#中创建一个HtmlInputCheckBox,我正在尝试为它设置一个CSS,但我不能。 Can anyone give me a sample code? 谁能给我一个示例代码?
For example, the one below is not working. 例如,下面的那个不起作用。

HtmlInputCheckBox FieldCtrl = new HtmlInputCheckBox();
FieldCtrl.ID = "CheckBox1";
FieldCtrl.Style = "CheckBox";

.Net不会直接暴露许多普通的HTML属性,但您可以通过Attributes集合访问它。

FieldCtrl.Attributes["class"] = "MyCssClass";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM