ASP.NET renders CheckBox control inside span if CssClass is set

I added an ASP.NET CheckBox control to a form I was creating and was surprised to see the following unexpected html rendered when CssClass property was set for the control: ASP.NET code: Rendered HTML: I tried adding the class attribute to the control’s Attributes collection in code-behind without success. Finally, after reading StackOverflow and MSDN, …

Continue reading

How To Validate A CheckBox ASP.NET Control

If you attempt to use a RequiredFieldValidator with a CheckBox control, you will get a runtime error that says something like “Control {your checkbox control id} referenced by the ControlToValidate property of {id of your validator control} cannot be validated”. If you want to require an ASP.NET CheckBox control be checked when a form is …

Continue reading