customvalidator tips

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.
Who is Participating?
MlandaTConnect With a Mentor Commented:
thanks for the tips :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.