How to use it?
- Put the library (Recaptcha.dll) in you application's bin directory.
- Register reCAPTCHA in the page where you want to use it by adding the following line - <%@ Register Assembly="Recaptcha" Namespace="Recaptcha" TagPrefix="recaptcha" %>
- Write the following piece of code to create reCaptcha control.
<ReCaptcha:RecaptchaControl ID="reCaptcha" runat="server"
PublicKey="Your Public Key"
PrivateKey="Your Private Key" />
- You can use Page.IsValid at code behind to check whether the CAPTCHA is valid or not.
if (Page.IsValid) // Check if Captcha is verified or not.
{
// Captcha provided by the user is valid.
}
else
{
// Captcha provided by the user is invalid.
}
Here i have written the code in the button click event (where the button is not the part of the reCaptcha control).
How to use Theme?
reCAPTCHA provides several themes like 'red', 'white', 'blackglass', 'clean'.
By code you can change the Theme of the reCAPTCHA control also. For applying theme we have to write the following code:
<ReCaptcha:RecaptchaControl ID="reCaptcha" runat="server" Theme="clean"
PublicKey="Your Public Key"
PrivateKey="Your Private Key" />
Here i have used the 'clean' theme.
How to reload reCAPTCHA?
Reloading reCAPTCHA indicates getting new set of images. If you are doing a complete page load then the reCAPTCHA images will load automatically but if you want to do a partial postback then you can reload the reCAPTCHA images throught javascript. By writng Recaptcha.reload(); in your javascript code you can reload the reCAPTCHA images.