Captcha is not validating properly when post back

4 posts, 1 answers
  1. Sumanth
    Sumanth avatar
    27 posts
    Member since:
    Sep 2010

    Posted 14 Feb 2011 Link to this post


      Below in my code in aspx and .cs files

    <asp:ScriptManager ID="sm" runat="server">
        <asp:UpdatePanel ID="upTest" runat="server" UpdateMode="Conditional">
                <asp:UpdatePanel ID="upPostBack" runat="server" UpdateMode="Conditional">
                        <asp:Button ID="btnPostBack" runat="server" Text="Post Back" OnClick="btnPostBack_Click" />
                        <asp:Label ID="lblPostBack" runat="server"></asp:Label>
                <asp:UpdatePanel ID="upc" runat="server" UpdateMode="Conditional">
                        <telerik:RadCaptcha CssClass="rcPanel" runat="server" IgnoreCase="true" CaptchaImage-UseRandomFont="false"
                            CaptchaImage-TextChars="LettersAndNumbers" CaptchaImage-RenderImageOnly="true"
                            ID="capSignup" ValidationGroup="valSignup" ValidatedTextBoxID="txtCaptcha" ErrorMessage="error"
                        <asp:TextBox runat="server" ID="txtCaptcha" validateexp="required,errMsg:Enter the above code"
                <asp:Button ID="btn" runat="server" OnClick="btn_Click" Text="Submit" ValidationGroup="valSignup" />
                <asp:Label ID="lbl" runat="server"></asp:Label>

    protected void btn_Click(object sender, EventArgs e)
           if (capSignup.IsValid)
               lbl.Text = "In Valid";
       protected void btnPostBack_Click(object sender, EventArgs e)
           lblPostBack.Text = DateTime.Now.ToShortTimeString();

    Captcha is working fine when i click on "Submit" button with out clicking "Post Back" button.
    If i click on "Post Back" then "Submit", IsValid property returns false.

    Could any one please help me.

  2. Answer
    Pero avatar
    1156 posts

    Posted 15 Feb 2011 Link to this post

    Hello Sumanth,

    The RadCaptcha always returns false, because after clicking the "Post Back" button, a new Captcha code is generated, but not shown on the image. RadCaptcha is designed to refresh its image on every postback and ajax request, no matter if the ajax request affects the image itself.
    To resolve the issue, please set UpdateMode="Always" to the UpdatePanel containing the RadCaptcha control.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Mouse
    Mouse avatar
    26 posts
    Member since:
    Sep 2009

    Posted 14 Jul 2011 Link to this post

    This is awful. So basically the image will keep refreshing.

    In my example, I have a timer ticking and it refreshes everytime the timer ticks. My timer is there to look for an Async process to be completed and when it is then things change on the page.

    Can you not configure this so that i can turn off the refresh?

    In my scenario the situation may occur where the user is typing into the box and the image changes so they will be required to retype the image text.

    Some advice on this matter would be helpful.

  4. Slav
    Slav avatar
    1359 posts

    Posted 19 Jul 2011 Link to this post

    Hi Phillip,

    A possible option in this case is to use Client Callback. When Callback occurs, the page doesn't go through full life-cycle and the code of the RadCaptcha isn't regenerated. You can implement this approach via our RadXmlHttpPanel, which loads data through Client Callbacks.

    In the online demos there is section with examples that demonstrate how RadXmlHttpPanel can be used. You can also check and utilize my attached project as a basis for your further development.

    I hope the provided information meets your requirements.

    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top