I'm trying to build a breadcrumb trail that will be represented by a list of site map nodes. the root node will be first, then the child, grandchild....... up until the current node. I'm trying to do this with recursion, but always getting the root node only:
public static List<MvcSiteMapNode> BreadcrumbTrail(MvcSiteMapNode curr)
{
List<MvcSiteMapNode> t = new List<MvcSiteMapNode>();
if (curr.ParentNode == null)
{
t.Add(curr);
return t;
}
else
return BreadcrumbTrail(curr.ParentNode as MvcSiteMapNode);
}
and the caller:
var curr = SiteMap.CurrentNode as MvcSiteMapNode;
List<MvcSiteMapNode> trail = BreadcrumbTrail(curr);