开发者

Using MvcSiteMapProvider to create menu

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 part开发者_JS百科ial view. please give me some code samples to get me started, or at least to make me feel less stupid ...thanks


public ActionResult SiteMap()
{
    //Do something to get the sitemap data
    var mySitemapData = CallToGetSiteMapData()
    return View(mySiteMapData);
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜