ASP.NET MVC3: How to get access to parameters passed as routeValues anonymous type in a HtmlHelper extension method?

I've figured out that I can use the constructor on the RouteValueDictionary which allows me to look up the Area property easily I also noticed I was complicating the issue by trying to use the controller value as well so my code now looks like the following: public static MvcHtmlString NavigationLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues) { string currentArea = htmlHelper.ViewContext.RouteData. DataTokens"Area" as string; if (IsInCurrentArea(routeValues, currentArea)) { return htmlHelper. ActionLink( linkText, actionName, controllerName, routeValues, new { @class = "active" }); } return htmlHelper.

ActionLink(linkText, actionName, controllerName, routeValues, null); } private static bool IsInCurrentArea(object routeValues, string currentArea) { if (routeValues == null) return true; var rvd = new RouteValueDictionary(routeValues); string area = rvd"Area" as string? Rvd"area" as string; return area == currentArea; }.

I've figured out that I can use the constructor on the RouteValueDictionary which allows me to look up the Area property easily. I also noticed I was complicating the issue by trying to use the controller value as well so my code now looks like the following: public static MvcHtmlString NavigationLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues) { string currentArea = htmlHelper.ViewContext.RouteData. DataTokens"Area" as string; if (IsInCurrentArea(routeValues, currentArea)) { return htmlHelper.

ActionLink( linkText, actionName, controllerName, routeValues, new { @class = "active" }); } return htmlHelper. ActionLink(linkText, actionName, controllerName, routeValues, null); } private static bool IsInCurrentArea(object routeValues, string currentArea) { if (routeValues == null) return true; var rvd = new RouteValueDictionary(routeValues); string area = rvd"Area" as string? Rvd"area" as string; return area == currentArea; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions