views:

28

answers:

1

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  A: 

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.

citronas