<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Load.aspx.cs" Inherits="Load" %>
<!DOCTYPE html>
<html xmlns="http:'www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src='https:'www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form id="form1" runat="server">
<label>Name</label>
<asp:TextBox ID="name" runat="server"></asp:TextBox>
<%
'You will need the new reCAPTCHA 2.0 Site Key for this.
'Go here: https:'www.google.com/recaptcha/admin
'And add a new Site Key for your website.
'For local testing, you will have to test with
'local/site.asp
'127.0.1/site.asp
'It will not work with a static IP Address as I would prefer.
%>
<div class="g-recaptcha" data-sitekey="6LeGzQATAAAAAGglcdHMRAuR8IOAdAFD47HpCZRQ"></div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
protected void Button1_Click(object sender, EventArgs e)
{
String strname = name.Text;
String captcha = Request.Form["g-recaptcha-response"];
//Next, we are going to make sure that each form variable has a value (Meaning: Filled out)
if (strname == null || strname == "")
{
Label1.Text = "Please provide your name";
//next, we are going to challenge the reCAPTCHA to make sure that it is not blank,
//and there is NO way around this. If it is not blank, then we send them a message.
}
else if (captcha == null || captcha == "")
{
Label1.Text = "You have not completed the <strong>reCAPTCHA</strong>
Please click on the blank box.
Thanks You";
}
else
{ // If the user has completed the reCAPTCHA, then we send a message letting them know.;
Label1.Text = "Thank you for trying out the
<strong>ASP.NET (C# Version) / Jquery reCAPTCHA 2.0</strong> demo.";
}
}