tags:

views:

206

answers:

1

Hello,

I am creating an HtmlInputCheckBox in C# and I am trying to set a css for it, but I cannot. 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";
+1  A: 

.Net doesn't directly expose a lot of the normal HTML attributes, but you can access it through the Attributes collection.

FieldCtrl.Attributes["class"] = "MyCssClass";
Chris Lively
Or: HtmlInputCheckBox FieldCtrl = new HtmlInputCheckBox(); FieldCtrl.Attributes.Add("class", "className");
ruslander