If you're building an ASP.NET 2.0 site that uses the SiteMenu control with a custom SiteMapProvider implementation as the underlying data source, take care how you populate the properties of the SiteMapNode objects you return from your custom SiteMapProvider class. While trying to fix some code here I noticed that the selected (i.e. current) menu item was not being marked correctly in the generated HTML, and eventually tracked down the problem to using an incorrect value in the SiteMapNode.Key property.

It seems that the MenuItem implementation of IHierachicalData.Path property returns the value of the Key property of the underlying SiteMapNode object it was created from (during databinding), instead of the Url of the node, but during databinding, the SiteMenu control compares the Url of the current page (i.e. the current node in the SiteMapProvider) to the IHierarchicalData.Path implementation of each databound menu item to determine which one is the selected one. If the Key property of the SiteMapNode does not match its Url, then it doesn't work.

Tomas Restrepo

Software developer located in Colombia.