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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With