Reputation: 800
I need to find out what level of the menu my current page is on.
I have access to the current node object using razor syntax within my HTML page:
@Html.MvcSiteMap().SiteMap.CurrentNode
Is there a property/method that can show the current nodes depth/level within the sitemap or do I need to write something to traverse the sitemap xml?
Upvotes: 1
Views: 542
Reputation: 17182
You need to use SiteMapPath() to get the breadcrumb menu -
@Html.MvcSiteMap().SiteMapPath()
Output would be shown like this -
Reference taken from here.
EDIT -
Can you try like this in View -
var depthCount = Html.MvcSiteMap().SiteMap.CurrentNode;
@depthCount.Ancestors.Count + 1 // will give you depth count
Upvotes: 2