我想使用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.HtmlHelper’ does not contain a deFinition for
‘ActionLink’ and no extension method ‘ActionLink’ accepting a first
argument of type ‘System.Web.Mvc.HtmlHelper’ Could be found (are you
missing a using directive or an assembly reference?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。