What's wrong with my HtmlHelper?
Posted
by Dejan.S
on Stack Overflow
See other posts from Stack Overflow
or by Dejan.S
Published on 2010-06-06T16:45:43Z
Indexed on
2010/06/06
16:52 UTC
Read the original article
Hit count: 260
asp.net-mvc
I done a htmlhelper but I can not get it to work tho. I did like I seen on different tutorials.
my MenuItemHelper static Class
public static string MenuItem(this HtmlHelper helper, string linkText, string actionName, string controllerName)
{
var currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"];
var currentActionName = (string)helper.ViewContext.RouteData.Values["action"];
var sb = new StringBuilder();
if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) && currentActionName.Equals(actionName, StringComparison.CurrentCultureIgnoreCase))
sb.Append("<li class=\"selected\">");
else
sb.Append("<li>");
sb.Append(helper.ActionLink(linkText, actionName, controllerName));
sb.Append("</li>");
return sb.ToString();
}
import namespace
<%@ Import Namespace="MYAPP.Web.App.Helpers" %>
Implementation on my master.page
<%= Html.MenuItem("TEST LINK", "About", "Site") %>
Errormessage I get
Method not found: 'System.String System.Web.Mvc.Html.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, System.String, System.String, System.String)
© Stack Overflow or respective owner