开发者

language option in reCAPTCHA ASP.NET plugin

I'm using ASP.NET plugin for reCAPTCHA in my ASP.NET MVC application. Recaptcha assembly version is 1.0.4.0. Is there a way to set language to be used for RecaptchaControl?

    var captchaControl = new Recaptcha.RecaptchaControl
            {
                ID = "recaptcha",
                Theme = "blackglass",
                PublicKey = "public_key",
开发者_Go百科                PrivateKey = "private_key"
            };


This feature was not supported in v1.0.4.0. Please download the latest version and try again.

http://code.google.com/p/recaptcha/downloads/detail?name=recaptcha-dotnet-1.0.5.0-binary.zip


with the help of this article here is how I've done it. the key is editing the generated html at the end; replacing "RecaptchaOptions = {" with "RecaptchaOptions = { lang : 'supported_language_code',"

public static string GenerateCaptcha(this HtmlHelper helper)
{
    var captchaControl = new Recaptcha.RecaptchaControl
            {
                ID = "recaptcha",
                Theme = "clean",
                PublicKey = "public_key_here",
                PrivateKey = "private_key_here"
            };
    var htmlWriter = new HtmlTextWriter(new StringWriter());
    captchaControl.RenderControl(htmlWriter);
    var html = htmlWriter.InnerWriter.ToString();
    html = html.Replace("RecaptchaOptions = {", "RecaptchaOptions = { lang : 'tr', ");
    return html;
} 

EDIT: A cleaner solution is given here. (System.Web.Helpers)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜