Monday, November 9, 2009

CustomValidator for Checkboxes in ASP.NET

To check that a checkbox is set in ASP.NET you need to do a little more than just grab a RequiredFieldValidator.Situation:

The RequiredFieldVadlidator cannot be used to validate ASP.NET Checkboxes.

Workaround:

Use a CustomValidator. All you need is implement the ServerValidate event of the Custom Validator to validate that the check-box is checked/unchecked. Read more: http://msdn.microsoft.com/en-us/library/aa479013.aspx

No comments: