Alessandro Zifiglio

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

All posts have moved to Typps

See you there.

Alessandro

Comments

Aaron said:

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...

# September 25, 2008 1:46 PM

alessandro said:

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 :-)

# September 26, 2008 9:02 AM

denniscy said:

Thank you, very useful.

# December 3, 2008 9:48 AM

Anonymouse said:

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

# December 7, 2008 11:32 PM

Javier said:

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.

# December 12, 2008 2:48 PM

alessandro said:

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.

# December 12, 2008 4:01 PM

Toby said:

Hi,

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

regards

toby.

# December 18, 2008 8:30 AM

Ben said:

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();

   }

}

# March 2, 2009 3:50 PM

Jose R. Guay Paz said:

Hi all. I was asked to add captcha to some web forms for contact and subscription information, so I though

# May 12, 2009 10:59 PM

Shriram said:

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

# June 12, 2009 5:08 AM

henry said:

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

any help?

thanks

# June 12, 2009 6:12 AM

Phil said:

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

# July 26, 2009 4:08 PM

Phil said:

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??

# July 26, 2009 4:39 PM

Automatically reload reCAPTCHA when postingback via a partial refresh (UpdatePanel) « Yasserzaid’s Weblog said:

Pingback from  Automatically reload reCAPTCHA when postingback via a partial refresh (UpdatePanel)  « Yasserzaid’s Weblog

# July 28, 2009 1:33 AM

narinder said:

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

# September 4, 2009 10:11 AM

Filipp said:

Thank you!  Just what I was looking for!

# September 25, 2009 6:24 PM

robin das said:

Great code dude its really working

# November 19, 2009 6:01 AM

JNF said:

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

# December 26, 2009 9:06 PM

Deeksha said:

Encountering the same problem as Henry and Phil.

Page.IsValid is always false.

What is the solution?

# March 24, 2010 4:00 PM

daya said:

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...

# April 16, 2010 9:12 AM

Adeola said:

What happens if the public and private keys are invalid?

# May 20, 2010 11:39 PM

sougandh said:

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

Best Regards,

Sougandh Pavithran

INDIA

# June 22, 2010 3:51 PM

Kameswari said:

Hi Sougandh,

Still Page.IsValid/recaptcha1.Isvalid always returns false.

How did you get a desired output? Please let me know.

Thanks,

Kameswari.

# July 14, 2010 2:01 AM

abdulwakeel said:

wa

# July 26, 2010 6:11 AM

Yonis said:

Thanks for your help! I needed to solve it!

# August 1, 2010 10:57 PM

ejseay said:

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?

# August 5, 2010 6:33 PM

swaps said:

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...

# August 25, 2010 9:18 AM

Laap said:

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

# November 9, 2010 7:34 PM

Alex Stoll said:

Thank you very much! Your solution worked nice!

# February 11, 2011 11:30 AM

Gorkem said:

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

# March 2, 2011 2:22 PM