Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I prevent RequiredFieldValidation from triggering against postbacks from a specific control

I have a web form with a number of textbox controls which I've associated RequiredFieldValidator's with. I have a ValidationSummary control on the page to render any incomplete fields when I submit the page.

However, I've just had to add an image upload facility to the same page, and have an 'Upload' button which I have posting back to perform the upload. I don't want this upload button to trigger the RequiredFieldValidators for the rest of the page though - I want this upload postback to be ignored as far as the validation goes.

What's the best way to stop the RequiredFieldValidator's from firing when I submit this upload button on the page because at the moment, the upload won't occur unless I have first filled out all of the other textbox controls on the page.

like image 542
marcusstarnes Avatar asked Dec 12 '25 07:12

marcusstarnes


1 Answers

set CausesValidation="false" on the image upload button

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.causesvalidation.aspx

like image 121
Daniel Dyson Avatar answered Dec 15 '25 05:12

Daniel Dyson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!