« Return to Thread: ASP.NET MVC setting menu items

ASP.NET MVC setting menu items

by Casey Charlton :: Rate this Message:

Reply to Author | View in Thread

Just playing around with a new navigation we have ... and the simplest way I
can think of at the moment to "select" the current page on the menus is
something like :

[NavigationHint("INDUSTRY ANALYSIS", "Headlines")]
public ActionResult Index()
{
   return View();
}

Where the attribute then puts these values into the ViewData collection for
the navigation controls to pickup ... this does mean that individual
methods/controllers don't have to worry about looking this data up or
remembering to set it

Obviously this means the navigation is set in code rather than in
configuration ... the slightly messier option to allow some external (to
code) configuration is to put in some kind of lookup in config somewhere ...


Any other (better) ideas for cross cutting data like this?

 « Return to Thread: ASP.NET MVC setting menu items