What's wrong with my HtmlHelper?
- by Dejan.S
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)