I try to create my own capcha (ctrlCapcha :UserControl) and I would like to use validator, which will display capcha error on ValidationSummary control.
At first I tried to create validator by inherit by BaseValidator class, but I can not pin it to my aspx file (<%@ Register %> doesn’t work)
At second I tried to use CustomValidator, but when I fix ID of my capcha control asp.net give me error “Control ‘ctrlCapcha’ referenced by the ControlToValidate property of ‘cusValCapcha’ cannot be validated.” (I service event “OnServerValidate”)
Could you tell me which way is better? Thank for you all suggestions 🙂
What are the fields that are inside the UserControl? I assume you want to validate one of these fields. You can add the Customvalidator to the UserControl itself and implement your ServerValidate inside the codebehind of the user control. You don’t have to set the “ControlToValidate” property. In the ServerValidate, you just add whether validation logic you want.