Automatically reload reCAPTCHA when postingback via a partial refresh (UpdatePanel)

All posts have moved to Typps

See you there.

Alessandro

27 Comments

  • Hmmm. This all makes sense, but I get an:

    Error: 'null' is null or not an object

    when I try to submit with an invalid entry in the reCaptcha...

  • hi Aron, unfortunately that didn't make any sense. I'm including the full source i used throughout this post above, in the hopes that it may help you further.
    Good luck :-)

  • Thank you, very useful.

  • alessandro, thank you so much for sharing your solution. It wasn't working at first, but after adding ChildrenAsTriggers="false" it worked perfectly!

  • Alessandro, what can I do if my Recaptcha is inside a MultiView which is encapsulated by a UpdatePanel? I applied your solution with no results. Thanks.

  • hi Javier, it would be faster to test your issue at hand if you can post some pseudocode, that way i know exactly under what condition it's failing.

  • Hi,

    Example works ok however it never returns a valid response. if the update panels are removed it works. any ideas?

    regards

    toby.

  • Calling the Validate method fixes the failure ti validate:
    public void btnSubmit_Click(object sender, EventArgs args)
    {
    recaptcha1.Validate();
    if (!recaptcha1.IsValid)
    {
    labelError.Text = "Incorrect, try again!";
    labelError.ForeColor = System.Drawing.Color.Red;
    //Reload recaptcha
    ScriptManager.RegisterClientScriptBlock(
    this.Page,
    this.Page.GetType(),
    "whatever1",
    "Recaptcha.reload();",
    true);
    UpdatePanel2.Update();
    }
    }

  • Hello ,
    I read above comments. Also I m getting same problem .
    do need to add
    " ScriptManager.RegisterClientScriptBlock(

    this.Page,

    this.Page.GetType(),

    "whatever1",

    "Recaptcha.reload();",

    true);"


    only you can update your update your update panel.
    problem will solved.
    Thanks

  • I have copied this, however it always returns false, even if i type in the words correctly.?!

    any help?

    thanks

  • I second Henrys problem. IT always returns false. Any solutions?

  • Actually, I take it back. It doesn't return false, rather, nothing at all happens. I added the following to the code-behind:

    if (recaptcha1.IsValid)
    {
    labelError.Text = "Great!";
    labelError.ForeColor = System.Drawing.Color.Green;
    }

    but as mentioned, the code doesn't execute??

  • I download your .dll file but its refference is not added into asp page . please tell me how we can add refference in asp.net.

    thanks for helf

  • Great code dude its really working

  • Amazing job!!thanks for the article....

  • Encountering the same problem as Henry and Phil.
    Page.IsValid is always false.
    What is the solution?

  • do recaptcha works on localhost?
    if yes, please tell me what is the process???

    I tried all above said, but I am getting always false in recaptcha.validate() method.

    please help me...

  • What happens if the public and private keys are invalid?

  • Thanks pal, the code worked and I have got the desired output with the code.

    Best Regards,
    Sougandh Pavithran
    INDIA

  • Hi Sougandh,

    Still Page.IsValid/recaptcha1.Isvalid always returns false.
    How did you get a desired output? Please let me know.

    Thanks,
    Kameswari.

  • wa

  • Thanks for your help! I needed to solve it!

  • I'm having a problem with this, it works for me but only on the first time I land on the page (like by typing the url in the browser). The reCaptcha is in my Master Page hidden in a JQueryUI dialog (modal). When I first land on the page everything works great, I can show the modal, use the form, and everything works. If i navigate to any other page using that master page, the page finishes loading, then automatically gets redirected to the reCaptcha on a blank white page...

    Any thoughts?

  • I tried this, however i keep getting a error still in recaptcha.js at e("recaptcha_challenge_field_holder") is null.Can u pls help...

  • Solution: ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "whatever1", "Recaptcha.reload();", true);

  • Thank you very much! Your solution worked nice!

  • Hi all,

    Recaptcha disappears after postback while using updatepanel. Doing the Recaptcha.Reload() does not solve the issue?

    Any help will be very appreciated.

    Thanks

Comments have been disabled for this content.