views:

15

answers:

1

This is a weird problem. I have created Web User Control with two TextBoxes and two CustomValidators (server-side only). I have also implemented IValidator interface and created ValidationGroup property that deafults to null.

The problem is that when I put this control on a website it doesn't block events when it's not valid. I've set CausesValidation on a Button that just reads proerty of my Web User Control and writes it to Label.

Any ideas why Button OnCLick event fires ALWAYS?

+1  A: 

Validators don't prevent the normal course of the asp.net lifecycle of a page. In your handler, you should check Page.IsValid and not do any of your normal processing if Page.IsValid = false

Dustin Hodges