I am trying to pass this code to mvc 6, any help is appreciated, compiling the code, but the method is not available in my views on @Html.IsActive .
using Microsoft.AspNet.Mvc.Rendering; namespace Blah.Web.Helpers { public static class HtmlHelpers { public static string IsActive(this HtmlHelper htmlHelper, string controller, string action) { var routeData = htmlHelper.ViewContext.RouteData; var routeAction = routeData.Values["action"].ToString(); var routeController = routeData.Values["controller"].ToString(); var returnActive = (controller == routeController && action == routeAction); return returnActive ? "active" : ""; } } }
In the view, I reference the namespace:
@using Blah.Web.Helpers;
c # asp.net-core asp.net-core-mvc
RickJames Dec 02 '14 at 19:14 2014-12-02 19:14
source share