language option in reCAPTCHA ASP.NET plugin

坚强是说给别人听的谎言 提交于 2019-12-11 13:46:12

问题


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",
                PrivateKey = "private_key"
            };

回答1:


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




回答2:


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)



来源:https://stackoverflow.com/questions/4432838/language-option-in-recaptcha-asp-net-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!