Asp.net Net MVC Recaptcha和严格的Doctype
我在我的MVC项目中使用了这种Recaptcha方法,但是它不能验证为严格的1.0 DOCTYPE 有人能帮忙吗Asp.net Net MVC Recaptcha和严格的Doctype,asp.net,asp.net-mvc,asp.net-mvc-2,recaptcha,Asp.net,Asp.net Mvc,Asp.net Mvc 2,Recaptcha,我在我的MVC项目中使用了这种Recaptcha方法,但是它不能验证为严格的1.0 DOCTYPE 有人能帮忙吗 谢谢创建您自己的控件。正如您在RecaptchaControl的RenderContents方法中所看到的,它使用iframe。Iframe不是严格遵从HTML的,因此必须使用HTML对象标记 protected override void RenderContents(HtmlTextWriter output) { output.AddAttribute(HtmlTextWri
谢谢创建您自己的控件。正如您在RecaptchaControl的RenderContents方法中所看到的,它使用iframe。Iframe不是严格遵从HTML的,因此必须使用HTML对象标记
protected override void RenderContents(HtmlTextWriter output)
{
output.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
output.RenderBeginTag(HtmlTextWriterTag.Script);
output.Indent++;
output.WriteLine("var RecaptchaOptions = {");
output.Indent++;
output.WriteLine("theme : '{0}',", this.theme ?? string.Empty);
if (this.customThemeWidget != null)
{
output.WriteLine("custom_theme_widget : '{0}',", this.customThemeWidget);
}
output.WriteLine("tabindex : {0}", this.TabIndex);
output.Indent--;
output.WriteLine("};");
output.Indent--;
output.RenderEndTag();
output.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
output.AddAttribute(HtmlTextWriterAttribute.Src, this.GenerateChallengeUrl(false), false);
output.RenderBeginTag(HtmlTextWriterTag.Script);
output.RenderEndTag();
output.RenderBeginTag(HtmlTextWriterTag.Noscript);
output.Indent++;
output.AddAttribute(HtmlTextWriterAttribute.Src, this.GenerateChallengeUrl(true), false);
output.AddAttribute(HtmlTextWriterAttribute.Width, "500");
output.AddAttribute(HtmlTextWriterAttribute.Height, "300");
output.AddAttribute("frameborder", "0");
output.RenderBeginTag(HtmlTextWriterTag.Iframe); // Change this to object HTML tag
output.RenderEndTag();
output.WriteBreak();
output.AddAttribute(HtmlTextWriterAttribute.Name, "recaptcha_challenge_field");
output.AddAttribute(HtmlTextWriterAttribute.Rows, "3");
output.AddAttribute(HtmlTextWriterAttribute.Cols, "40");
output.RenderBeginTag(HtmlTextWriterTag.Textarea);
output.RenderEndTag();
output.AddAttribute(HtmlTextWriterAttribute.Name, "recaptcha_response_field");
output.AddAttribute(HtmlTextWriterAttribute.Value, "manual_challenge");
output.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
output.RenderBeginTag(HtmlTextWriterTag.Input);
output.RenderEndTag();
output.Indent--;
output.RenderEndTag();
}
创建自己的控件。正如您在RecaptchaControl的RenderContents方法中所看到的,它使用iframe。Iframe不是严格遵从HTML的,因此必须使用HTML对象标记
protected override void RenderContents(HtmlTextWriter output)
{
output.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
output.RenderBeginTag(HtmlTextWriterTag.Script);
output.Indent++;
output.WriteLine("var RecaptchaOptions = {");
output.Indent++;
output.WriteLine("theme : '{0}',", this.theme ?? string.Empty);
if (this.customThemeWidget != null)
{
output.WriteLine("custom_theme_widget : '{0}',", this.customThemeWidget);
}
output.WriteLine("tabindex : {0}", this.TabIndex);
output.Indent--;
output.WriteLine("};");
output.Indent--;
output.RenderEndTag();
output.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
output.AddAttribute(HtmlTextWriterAttribute.Src, this.GenerateChallengeUrl(false), false);
output.RenderBeginTag(HtmlTextWriterTag.Script);
output.RenderEndTag();
output.RenderBeginTag(HtmlTextWriterTag.Noscript);
output.Indent++;
output.AddAttribute(HtmlTextWriterAttribute.Src, this.GenerateChallengeUrl(true), false);
output.AddAttribute(HtmlTextWriterAttribute.Width, "500");
output.AddAttribute(HtmlTextWriterAttribute.Height, "300");
output.AddAttribute("frameborder", "0");
output.RenderBeginTag(HtmlTextWriterTag.Iframe); // Change this to object HTML tag
output.RenderEndTag();
output.WriteBreak();
output.AddAttribute(HtmlTextWriterAttribute.Name, "recaptcha_challenge_field");
output.AddAttribute(HtmlTextWriterAttribute.Rows, "3");
output.AddAttribute(HtmlTextWriterAttribute.Cols, "40");
output.RenderBeginTag(HtmlTextWriterTag.Textarea);
output.RenderEndTag();
output.AddAttribute(HtmlTextWriterAttribute.Name, "recaptcha_response_field");
output.AddAttribute(HtmlTextWriterAttribute.Value, "manual_challenge");
output.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
output.RenderBeginTag(HtmlTextWriterTag.Input);
output.RenderEndTag();
output.Indent--;
output.RenderEndTag();
}
我会通过NuGet软件包参考推荐MicrosoftWebHelpers库
这里有一篇博文:我想通过NuGet软件包参考推荐Microsoft Web Helpers库
下面是一篇博文:您想要什么帮助?为了让它通过严格的doctype验证,我刚刚查看了源代码,它使用了iframe,因此无论如何都不会通过。羞耻。recaptcha Group的人建议我使用HTML5 Doctype-我添加了HTML5 Doctype,但由于iframe上的frameborder属性,它仍然失败。您希望得到什么帮助?为了让它通过严格的Doctype验证,我只查看了源代码,它使用了iframe,所以无论如何都不会通过。羞耻。recaptcha Group的人建议我使用HTML5 Doctype——我添加了HTML5 Doctype,但由于iFrame上的frameborder属性,它仍然失败