How to use reCaptcha with c#

Hello all,

Today i want to share example of reCaptcha. Some of us have try to implement reCaptcha with c# but they are facing some issues to implement it. So, i have create one simple example with update panel.

First register your site at By clicking on create key you will get your public key and private key. We will need this key to implement our captcha.

Now, we need recaptcha.dll for c#. You will get dll from here or go to resourses in recaptcha site.

We are ready to code in our application. First add below code in your aspx page.

// Add to register captcha
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

// Add in your page html

Post a Comment

Now, add following code in cs file.

// Add following code for your button btnSubmit_Click event.
if (Page.IsValid && recaptcha.IsValid)
     // your code here
        divRecaptcha.Visible = true;
          + "if ( RecaptchaOptions && \"custom\" == RecaptchaOptions.theme )"
          + "{"
          + "  if ( RecaptchaOptions.custom_theme_widget )"
          + "  {"
          + "    Recaptcha.widget = Recaptcha.$(RecaptchaOptions.custom_theme_widget);"
          + "    Recaptcha.challenge_callback();"
          + "  }"
          + "} else {"
          + "  if ( Recaptcha.widget == null || !document.getElementById(\"recaptcha_widget_div\") )"
          + "  {"
          + "    jQuery(\"#" + divRecaptcha.ClientID + "\").html('
');" + " Recaptcha.widget = Recaptcha.$(\"recaptcha_widget_div\");" + " }" + " Recaptcha.reload();" + " Recaptcha.challenge_callback();" + "}", true ); }

Here, script manager block is for reload the captcha when captcha is incorrect. I have faced many issues to implement captcha like my dialog box is not submited, captcha is submit but invalid captcha enter and reload captcha not done etc…

Use custom validator to validate reCaptcha. Also, reload captcha issue solved by script manager.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>