what goes in the code behind for the Server Validate event of a Custom Validator, which is attempting to validate a set of 2 radiobuttons?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Mainly you need to specify your custom logic and if everything passes satisfactorily you would set
args.IsValid = true;otherwise, you would set it tofalse. The set ErrorMessage will appear if validation fails.The basic outline is as follows:
For example, given radio buttons r1 and r2 you might have logic like this to ensure one of them is selected:
The above could’ve been assigned directly in one line, but is expanded for clarity. As another example, you may have an “Other” type of button with an associated “If you selected other, please explain:” textbox. You could check if the other radio is selected, then check the textbox etc.