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

    Hi,

      Below in my code in aspx and .cs files

    <asp:ScriptManager ID="sm" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="upTest" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:UpdatePanel ID="upPostBack" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:Button ID="btnPostBack" runat="server" Text="Post Back" OnClick="btnPostBack_Click" />
                        <asp:Label ID="lblPostBack" runat="server"></asp:Label>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <asp:UpdatePanel ID="upc" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <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"
                            IsValid="true">
                        </telerik:RadCaptcha>
                        <asp:TextBox runat="server" ID="txtCaptcha" validateexp="required,errMsg:Enter the above code"
                            ValidationGroup="valSignup"></asp:TextBox>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <asp:Button ID="btn" runat="server" OnClick="btn_Click" Text="Submit" ValidationGroup="valSignup" />
                <asp:Label ID="lbl" runat="server"></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>

    protected void btn_Click(object sender, EventArgs e)
       {
           capSignup.Validate();
           Page.Validate();
           if (capSignup.IsValid)
               lbl.Text="Valid";
           else
               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.

    Thanks,
    Sumanth
  2. Answer
    Pero
    Admin
    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,
    Pero
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. 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.

    Thanks
    Phil
  5. Slav
    Admin
    Slav avatar
    1355 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.

    Regards,
    Slav
    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