asp.net-mvc-3 – System.Web.Mvc.HtmlHelper’不包含’ActionLi
发布时间:2020-12-15 18:39:19 所属栏目:asp.Net 来源:网络整理
导读:我想使用custom @ Html.ActionLink 我试图使用以下代码: public static class LinkExtensions{ public static MvcHtmlString MyActionLink( this HtmlHelper htmlHelper,string linkText,string action,string controller) { var currentAction = htmlHelpe
我想使用custom @ Html.ActionLink
我试图使用以下代码: public static class LinkExtensions { public static MvcHtmlString MyActionLink( this HtmlHelper htmlHelper,string linkText,string action,string controller) { var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action"); var currentController = mlHelper.ViewContext.RouteData.GetRequiredString("controller"); if (action == currentAction && controller == currentController) { var anchor = new TagBuilder("a"); anchor.Attributes["href"] = "#"; anchor.AddCssClass("currentPageCSS"); anchor.SetInnerText(linkText); return MvcHtmlString.Create(anchor.ToString()); } return htmlHelper.ActionLink(linkText,action,controller); } } 从Custom ActionLink helper that knows what page you’re on 但我得到了
解决方法
使用System.Web.Mvc.Html添加在您的文件的顶部
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – GridView不记得回发之间的状态
- 我想学习ASP.Net 2.0 / 3.5 / 4.0我应该从ASP.Net 2.0开始,
- asp.net-web-api – WebApi 2超出最大请求长度
- .net中基于资源的授权
- asp.net-core – 用于Core的DocumentDB TransientFaultHand
- asp.net-mvc – 为什么HttpContext.Current在asp.net mvc中
- asp.net-mvc-3 – 没有使用asp mvc 3,nhibernate 3.2和spri
- asp.net – MVC控制器和视图应该有1到1的关系吗?
- EF数据库初始化策略及种子数据的添加
- asp.net – 在mod_mono和Apache上的Appdomain回收设置
推荐文章
站长推荐
- asp.net-mvc – 实体框架SQLite部署
- asp.net – SignalR(Hub)可以发送除信号制作者之
- ASP.NET Ajax库死了吗?
- asp.net-mvc-3 – Facebook身份验证和奇怪的重定
- 通过LAN调试ASP.NET云项目
- Application_Start不被ASP.NET网页应用程序打中
- asp.net-mvc – 在ajax调用中ASP.NET MVC错误的u
- asp.net – ActionLink为Attribute Route生成错误
- asp.net – MVC Child Action在Path中抛出非法字
- 深入理解C# 3.x的新特性(1): Anonymous Type
热点阅读