views:

37

answers:

2

Hi. Sorry if this seems like a novice question. I'm trying to create a navigation menu that will be displayed in every page of my mvc site. I'm using MvcSiteMapProvider, and the general idea is to create a general ApplicationController, which every controller inherits.

public abstract class ApplicationController : Controller
{
    public ActionResult SiteMap()
    {
        return View();
    }
}

then create a partial/user control that will maybe use the html helper

<%=Html.MvcSiteMap().Menu("siteMap")%>

and call the user control in my master page... but I don't know how to pass the site map data to the partial view. please give me some code samples to get me started, or at least to make me feel less stupid ...thanks

A: 
public ActionResult SiteMap()
{
    //Do something to get the sitemap data
    var mySitemapData = CallToGetSiteMapData()
    return View(mySiteMapData);
}
Simon Hazelton
Actually, my problem is how to get the site map data with MvcSiteMapProvider to populate the menu
olst
A: 

Actually, got it working by adding the appropriate dll reference and using

<%=Html.MvcSiteMap().Menu("siteMap")%> 

for the menu in the master page, but now I was wondering, how to make the menu dynamic, so that it'll display two levels of the site map or more

olst