This is a migrated thread and some comments may be shown as answers.

radCaptcha in ASCX user control does not validate on first attempt (but does on subsequent postbacks)

1 Answer 71 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Paul Robertson
Top achievements
Rank 1
Paul Robertson asked on 12 Sep 2012, 04:22 PM
Dear Telerik

Please could you advise if there is a workaround for my scenario, which is causing inconsistent validation behaviour in the radCaptcha control.

I have an ASCX user control in which a radCaptcha is added DECLARATIVELY in the ASCX markup. I use the <captchacontrol_id>.Validate and Page.Validate(<myvalidationgroup>) functions in my server-side button handler. On the user's first attempt to use the page to postback with validation, the IsValid property switches incorrectly to False as a result of running these functions, even if the captcha code is entered correctly. However, if the user tries again, the validation is successful, with the expected IsValid value of False being shown.

I do not believe this is directly a problem with my code, because this behaviour is only seen in the situation when the HttpRuntime process has to start up to serve the page. If the process is already running from previous requests, the 'first attempt failure' problem I describe above does not occur. It is as though the httphandler in Telerik.Web.UI.WebResource.axd is not ready until after the first postback. I have tried using the HttpHandlerUrl property to see if this serves to 'preload' the httphandler, but this does not seem to make any difference, e.g.:

myCaptchaId.HttpHandlerUrl = "~/Telerik.Web.UI.WebResource.axd"

I have also tried moving the <captchacontrol_id>.Validate and/or Page.Validate(<myvalidationgroup>) functions to different places in the page life cycle before the button handler runs, and in various 'If Page.IsPostBack' clauses, but this also is not useful. The problem of the initial validation failure remains consistent.

I am wondering if you could advise me about the best way of resolving this issue, as I believe I have now spent more time than is reasonable (several days) trying to resolve the problem. For example, can you me of any workaround for my scenario that would ensure that the radCaptcha control and the httphandler would be ready to perform the correct validation behaviour on the first attempt?

Thankyou for your advice on the problem.

Regards

Paul


1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 17 Sep 2012, 12:57 PM
Hi Paul,

The RadCaptcha is validated when you perform a postback via controls with CausesValidation set to true. The Validate method is usually used when you want to invoke validation earlier in the page lifecycle, for example on Page_Load.

I will need more information about your scenario in order to help you accordingly as I am unable to suggest a solution based on the information you provided. What is the setup of the RadCaptcha control on your page? Can you describe what should be changed in a standard configuration of the control, as shown in this online demo, so that the problem is reproducible?

All the best,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Captcha
Asked by
Paul Robertson
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or