Captcha in ASCX UserControl?? Works? Hmmm.

2 posts, 0 answers
  1. Robert
    Robert avatar
    56 posts
    Member since:
    Feb 2010

    Posted 16 Sep 2010 Link to this post

    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? 
  2. Pero
    Pero avatar
    1156 posts

    Posted 21 Sep 2010 Link to this post

    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:

    ///source code

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

    Sincerely yours,
    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
Back to Top