We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

asp.net customvalidator tips

brotherbill999
on
Medium Priority
284 Views
Last Modified: 2012-05-11
A Custom Validator can be quite tricky to get right.
Here are some tips that were used in a hairy validation.
For starters, lets assume that there is a checkbox and textbox that work together in validation.

1. Add a textbox which is non-empty to act as the ControlToValidate in the CustomValidator.
    Set style="display:none" so it doesn't display.
    Other code will be looking for it, and gripe if it is null.
2. Assign the ErrorMessage in the CustomValidator.
    You can't set it an client run time.
3. Provide OnServerValidate function in code-behind.
4. Add ClientValidationFunction
    Set args.IsValid = true or false

No response needed.
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.