Jeff Prosise made a nice blog entry about hiding the root node in the SiteMapPath-control. Some people, like myself, experienced an issue when the current node and the root node ar actually the same. Somehow the check that should avoid that issue fails. I believe because the current node is in fact a clone of the current node, and as such not equal to the current node (i.e. root node) itself. To get around this, I have changed the code somewhat to do the check on the actual nodes. The body of the HideRootNode-method is now as follows:
// Return root node in case this is the root.if(SiteMap.RootNode == SiteMap.CurrentNode) return SiteMap.CurrentNode;// This is not the root node, so rebuild path without root.SiteMapNode node = SiteMap.CurrentNode.Clone();SiteMapNode current = node;while (node.ParentNode != SiteMapNode.RootNode){ node.ParentNode = node.ParentNode.Clone(); node = node.ParentNode;}node.ParentNode = null;return current;
Thanks to Jeff for his original insight. It saved me a lot of time.
Remember Me
a@href@title, strike
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.