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) {
args.Item.ImageUrl = ((SiteMapNode)args.Item.DataItem)["imageUrl"];
}
Have fun codding!
The Source code of this above article can downloaded from www.Gotdotnet.com Website.
Here's a link to the full source code:
Download the source code