0

I am extending the TextBox class to include CustomValidator along with the TextBox. I have created properties like CSSClass for ErrorMessage, CustomErrormessage for ErrorMessage on failure. But I am not sure how to get server side validation method in the form of tag. Example:

 <asp:CustomValidator runat="server" id="custPrimeCheck"
        ControlToValidate="txtPrimeNumber"
        OnServerValidate="PrimeNumberCheck"
        ErrorMessage="Invalid Prime Number" />

PrimeNumberCheck is the method name which is passed as parameter, same way I want to pass method in my custom TextBox for CustomValidator to run on server side.

Is there any way to achieve this functionality, or how would you implement this?

1 Answer 1

1

I'm not sure whether this is possbiel in the markup. The signature of the method PrimeNumberCheck must match (if I'm not mistaken)

(object sender, ServerValidateEventArgs e)

You may get it working by fully referencing the method in the markup, or by manually assigning the function to the property in the code-behind.

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

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.