Reputation: 11
I am working in MVC3.0 and I want to implement Captcha (Google service) on a pop up. Now the problem is the pop up is made by ajax call.
In AJAX call the pop up Re captcha is not coming but in a normal pop up it is coming correctly.
I followed the following steps:
Step 1: I included this in Email.cshtml
@Html.Raw(Html.GenerateCaptcha())
Step 2: Generate this function in my .cs file:
public static string GenerateCaptcha(this HtmlHelper helper)
{
var captchaControl = new RecaptchaControl
{
ID = "recaptcha",
Theme = "clean", //http://wiki.recaptcha.net/index.php/Theme
PublicKey = ConfigurationManager.AppSettings["ReCaptchaPublicKey"],
PrivateKey = ConfigurationManager.AppSettings["ReCaptchaPrivateKey"]
};
var htmlWriter = new HtmlTextWriter(new StringWriter());
captchaControl.RenderControl(htmlWriter);
return htmlWriter.InnerWriter.ToString();
}
Step 3: Then add public and private key in web.config and also add the necessary namespace
I followed all the steps.
Can someone please suggest if pop up is made by Ajax call and if I have to implement captcha in Ajax pop up then what do I have to do?
Regards, Sahil
Upvotes: 1
Views: 719