protected void Page_Load(object sender, EventArgs e) { //Place your site key and secret key here Recaptcha recaptcha = new Recaptcha("google_site_key", "google_secret_key"); googleRecaptcha.InnerHtml = recaptcha.GetSecureTokenHTML(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show(@"Please provide google site key!"); return; } if (textBox2.Text == "") { MessageBox.Show(@"Please provide google secret key!"); return; } Recaptcha recaptcha = new Recaptcha(textBox1.Text, textBox2.Text); textBox3.Text = recaptcha.GetSecureTokenHTML(); }
protected void btnValidateRecaptcha_Click(object sender, EventArgs e) { Recaptcha recaptcha = new Recaptcha("google_site_key", "google_secret_key"); string recaptchaResponse = HttpContext.Current.Request.Form["g-recaptcha-response"]; RecaptchaValidationResult validationResult = recaptcha.Validate(recaptchaResponse); if (validationResult.Succeeded) { trMsg.Visible = true; trMsg.Attributes["class"] = "alert alert-success"; trMsg.InnerHtml = "Congrats it validated successfully"; } else { trMsg.Visible = true; trMsg.Attributes["class"] = "alert alert-danger"; trMsg.InnerHtml = "Oops something went wrong. Error detail: " + validationResult.GetErrorMessagesString(); } }
protected void btnValidateRecaptcha_Click(object sender, EventArgs e) { Recaptcha recaptcha = new Recaptcha("google_site_key", "google_secret_key"); string recaptchaResponse = HttpContext.Current.Request.Form["g-recaptcha-response"]; RecaptchaValidationResult validationResult = recaptcha.Validate(recaptchaResponse); if (validationResult.Succeeded) { trMsg.Visible = true; trMsg.Attributes["class"] = "alert alert-success"; trMsg.InnerHtml = "Congrats it validated successfully"; } else { trMsg.Visible = true; trMsg.Attributes["class"] = "alert alert-danger"; trMsg.InnerHtml = "Oops something went wrong. Error detail: " + validationResult.GetErrorMessagesString(); } }
protected void Page_Load(object sender, EventArgs e) { //Place your site key and secret key here Recaptcha recaptcha = new Recaptcha("google_site_key", "google_secret_key"); googleRecaptcha.InnerHtml = recaptcha.GetSecureTokenHTML(); }