What to do when your ASP.NET Custom Validator Control isn't firing.

Don't be like me and debug a custom validator control for hours trying to figure out why it's ServerValidate event won't fire. Instead read this question and discover the magic that is ValidateEmptyText="true". Had I known that custom validator controls had this property I would have saved myself a couple hours of work. I was validating a file upload control and became dumbfounded when I couldn't hit breakpoints in the validator's server-side event. It must be Friday because my brain was too fried to realize that the breakpoints weren't being hit because the event wasn't being called!

If you set the ControlToValidate property on a custom validator and you want it to fire even if the control you're validating is empty, then make sure ValidateEmptyText is set to true and you won't have to make my same mistake and waste precious time.

Chev

Read more posts by this author.

comments powered by Disqus