I’m working on a project at the moment that requires a navigation menu built with ASP.Net 2.0. The requirements dictate that the navigation elements should be configured in an XML file. This sounded perfect for the ASP.Net siteMap provider so I set about implementing a SiteMapDataSource and binding a TreeView control to it.
This worked fine however each top level menu item had to be collapsable with a ‘scrolling’ animation and this was implemented using jquery. The only thing was, I didn’t want a postback to occur when the user clicked on each menu item which is the default action with the TreeView control.
In ASP.Net 1.1 you could set AutoPostBack property of the TreeView control to false and this would supress postbacks for every node. This property is missing in ASP.Net 2.0 so I set about finding a solution to the problem. Unfortunately there wasn’t much on the web about how to solve this particular problem but I did end up finding a solution that worked a treat.
Now when a user clicks on the node a postback will not occur which is exactly what I needed.