1

How to define client-side logic in new ASP.NET validator (not CustomValidator). Can you point me to articles where whole process is described?

2 Answers 2

1

This article goes through the process of creating a new custom validator by deriving from BaseValidator instead of CustomerValidator.

The trick for getting ASP.NET to execute your JS code is this (in AddAttributesToRender()):

if(this.RenderUplevel) {
    string clientID = this.ClientID;
    Page.ClientScript.RegisterExpandoAttribute(clientID, 
        "evaluationfunction", 
        "MultipleFieldsValidatorEvaluateIsValid");
}

ASP.NET will then call MultipleFieldsValidatorEvaluateIsValid().

Also, see How do I hook up javascript to my CustomValidator control in .Net

Sign up to request clarification or add additional context in comments.

Comments

0

In the ASP.NET MVC world, there's a wonderful validation framework called xVal, which I have used with great success. Apparently there is a port for ASP.NET, xVal for WebForms. I have not used it, but it might be worth a try. Good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.