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

Captcha in ASCX UserControl?? Works? Hmmm.

1 Answer 42 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Роберт
Top achievements
Rank 1
Роберт asked on 16 Sep 2010, 10:39 AM
When load ascx user control with captcha and it's never been validated, even if I enter right code which I can see on a textbox by captcha.CaptchaImage.Text.
Pero, you wrote " register the UserControl directly in the .aspx page, or load it at Page.Init"

How can I do it?

I'm doing 

        Contact contact;
        protected void Page_Load(object sender, EventArgs e)
        {
            contact = (Contact)Page.LoadControl("~/Contact.ascx");
        }

in .aspx file

then, on menu (in aspx) selection, I fill PlaceHolder with 
contact by myPlaceHolder.Controls.Add(contact)

I set all elements in my ValidationGroup with SubmitGroup. SubmitButton and captcha as well.
All elements from the resulting page, such as RequiredFieldValidator (3 of them at the form) are working ok, but the captcha IsValid property is always false.

What am I doing wrong? 

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 21 Sep 2010, 03:08 PM
Hi Vitali,

In order for the RadCaptcha to work correctly in a UserControl scenario, the UserControl must be loaded in the Page_Init, if created dynamically, or registered directly on the Page. So, please change your source code to load the control in the Page_Init, and see if you still get the same behavior. You can also call RadCaptcha.Validate(), and Page.Validate() methods before, checking the IsValid properties, just to be sure that the Validation has occurred. Here is a sample code:

RadCaptcha1.Validate();
Page.Validate();
 
if(RadCaptcha1.IsValid)
{
///source code
}

We will do our best to improve the control in one of our future releases.

Sincerely yours,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Captcha
Asked by
Роберт
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or