赞
踩
这就是我的Html助手的样子:
namespace WebApp.WebUI { public static class HtmlExtensions { public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper, string theme) { string publicKey = ConfigurationManager.AppSettings["CaptchaKey_Public"]; string privateKey = ConfigurationManager.AppSettings["CaptchaKey_Private"]; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = theme, PublicKey = publicKey, PrivateKey = privateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return new MvcHtmlString(htmlWriter.InnerWriter.ToString()); } } }
我试过在这个视图中使用它:
@{ ViewBag.Title = "Register"; } @model WebApp.WebUI.ViewModel.RegisterModel @using (Html.BeginForm("Register", "Auth", FormMethod.Post, new { Id = "ERForm" })) { @Html.GenerateCaptcha("clean") }
它给了我这个错误:
CS1061: 'System.Web.Mvc.HtmlHelper
我究竟做错了什么.我的命名空间是正确的.它没有出现在intellisense中@Html
你可以添加:
@using WebApp.WebUI
在你的剃刀视图的顶部.
如果你想在许多不同的视图中重用这个帮助器,以避免每次添加using子句,你可以将它添加到文件的
部分~/Views/web.config
:
执行此操作后,请确保重新编译并重新打开智能感知的Razor视图,以便有时间进行搜索.
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/blog/MFC/detail/22325赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。