How to use CSS on an Html.ActionLink in C#

此生再无相见时 提交于 2019-11-30 17:36:47

Make sure you are using the proper overload:

<%: Html.ActionLink("Home", "Index", "Home", null, new { @class = "NavLink" })%>
                                              ^                ^
                                          routeValues    htmlAttributes

Method Actionlink have some overloading.

If you want to determine some html attributes, you should use such methods(in your case):

  ActionLink(HtmlHelper, String, String, RouteValueDictionary, IDictionary<String, Object>)
  ActionLink(HtmlHelper, String, String, String, Object, Object)
  ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

More about this here: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink.aspx

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