<siteMapNode url="default.aspx" title="Home" description="The home page" imageUrl="home.gif">
I think it is very easy to bind a Menu to a SiteMapDataSource , it can prove challenging to find how to extend the sitemap with custom properties and use these extended properties in a Menu. This Article shows how to add icons in a sitemap-driven menu.
SiteMap allows the addition of custom attributes to your site map nodes. If you're using the XML site map provider, it's as simple as this:
The first idea that comes to mind to use these custom attributes is to just replace the automatic bindings you get from binding a Menu to SiteMapDataSource with "manual" bindings. This works very well with XmlDataSource because it is implemented so that the nodes implement ICustomTypeDescriptor , so any XML attribute is exposed as a property on the node as far as reflection is concerned. This is a very powerful feature of .NET reflection that gives it some of the qualities of dynamic languages. Unfortunately, SiteMapDataSource does not implement this, nor does Menu know how to query custom site map attributes. This is an oversight and we may add that support in future releases. An easy (although not declarative) way out of this problem is to hook the OnMenuItemDataBound event and to set the custom properties from there: public void OnItemBound(object sender, MenuEventArgs args) { |