Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中将css类设置为HtmlInputCheckBox#_C#_Asp.net_.net_Css_Checkbox - Fatal编程技术网

C# 在C中将css类设置为HtmlInputCheckBox#

C# 在C中将css类设置为HtmlInputCheckBox#,c#,asp.net,.net,css,checkbox,C#,Asp.net,.net,Css,Checkbox,我正在用C#创建一个HtmlInputCheckBox,并试图为其设置css,但我不能。谁能给我一个示例代码 例如,下面的一个不起作用 HtmlInputCheckBox FieldCtrl = new HtmlInputCheckBox(); FieldCtrl.ID = "CheckBox1"; FieldCtrl.Style = "CheckBox"; .Net并没有直接公开很多普通的HTML属性,但您可以通过attributes集合访问它 FieldCtrl.Attributes["c

我正在用C#创建一个HtmlInputCheckBox,并试图为其设置css,但我不能。谁能给我一个示例代码
例如,下面的一个不起作用

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

.Net并没有直接公开很多普通的HTML属性,但您可以通过attributes集合访问它

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

在您的示例中,将字段定义为field,并引用它FieldCtrl。这是示例中的输入错误还是代码中的问题?对不起,这是输入错误。拼写错误已修复..或:HtmlInputCheckBox FieldCtrl=new HtmlInputCheckBox();FieldCtrl.Attributes.Add(“类”、“类名”);