Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Captcha > Captcha is not validating properly when post back

Answered Captcha is not validating properly when post back

Feed from this thread
  • Sumanth avatar

    Posted on Feb 14, 2011 (permalink)

    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

    Reply

  • Answer Pero Pero admin's avatar

    Posted on Feb 15, 2011 (permalink)

    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.

    Reply

  • Mouse avatar

    Posted on Jul 14, 2011 (permalink)

    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

    Reply

  • Slav Slav admin's avatar

    Posted on Jul 19, 2011 (permalink)

    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!

    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Captcha > Captcha is not validating properly when post back