Exemple #1
0
        public static IHtmlString ActiveIfCurrent(this WebViewPage page, NavUrl navUrl)
        {
            var request = page.Request;
            string areaName = (string)request.RequestContext.RouteData.DataTokens["area"] ?? "";
            string controllerName = (string)request.RequestContext.RouteData.Values["controller"] ?? "";
            string actionName = (string)request.RequestContext.RouteData.Values["action"] ?? "";

            var isTypeOk = true;
            if (navUrl.Type != null && navUrl.Type.Trim().Length > 0)
            {
                string type = request.Params[NavUrl.TypeParam] ?? "";
                isTypeOk = navUrl.Type == type;
            }

            if (navUrl.Area == areaName && navUrl.Controller == controllerName && navUrl.Action == actionName && isTypeOk)
            {
                return page.Html.Raw("class=\"active\"");
            }
            return page.Html.Raw("");
        }
Exemple #2
0
 public static string GenerateUrl(this WebViewPage page, NavUrl navUrl)
 {
     return page.Url.Action(navUrl.Action, navUrl.Controller, navUrl.RouteValues);
 }