views:

31

answers:

1

I am having a problem where my button click event is still firing even though my custom server-side validation is set to args.IsValid = false. I am debugging through the code and the validation is definitely being fired before the button click, and args.IsValid is definitely being set to false once the custom validation takes place, but it always makes its way to the button click event afterwards. Any ideas on why this is?

+1  A: 

Not sure 100% of the particulars, but to prevent code from continuing, add to your button click event handler:

if (!Page.IsValid)
     return;

That will prevent the code from executing.

Brian
Ah yes. Completely forgot that piece.
Josh