ASP.NET 2.0 TreeView is bindable with one sitemap per
website only named with Web.sitemap. The ASP.NET Sitemap Provider only looks
for a site map with this name. The only way to use multiple sitemaps is to nest
the sitemaps, having the parent with same name, Web.sitemap. No matter even if
you will add another TreeView control on page, it again expects the
Web.sitemap. It does not work in salutations where we want to customize the
look of a tree view according to the category. The Extended TreeView works
great for us and overcomes this problem. Now we can use as many sitemaps as we
wish in a website (without nesting) and can bind them with their corresponding
To work with multiple sitemaps follow these steps.
Add a new sitemap to your web site and name it, say
CommonUser.sitemap. Save it in any folder, preferably App_Data for security
reasons. This will not allow the client to see it. All contents of this folder
are inaccessible to the client.
Add nodes and set their properties in the sitemap file as
<?xml version="1.0" encoding="utf-8" ?>
<siteMapNode value="~/Home.aspx" title="Home">
<siteMapNode value="~/Default.aspx" title="User Tasks" >
<siteMapNode value="~/Profile.aspx" title="View" >
<siteMapNode value="~/Profile.aspx" title="Profile" />
<siteMapNode value="~/WeeklyWorkTimeDetail.aspx" title="Work Time Detail" >
<siteMapNode value="~/WeeklyWorkTimeDetail.aspx" title="Weekly"/>
<siteMapNode value="~/MonthlyWorkTimeDetail.aspx" title="Monthly"/>
<siteMapNode value="~/YearlyWorkTimeDetail.aspx" title="Yearly"/>
<siteMapNode value="~/WarningComments.aspx" title="Warning and Comments" />
DO NOT use URL property of node, use Value property instead.
By using URL browser, it transfers to the next page without making a server
round trip that does not allow saving the expansion sate of the nodes on
server. Yet by using VALUE property the page is redirected; a server round trip
provides a chance to save the expansion state.
Drag the XTreeView control from the control bar and drop on
<cc1:XTreeView ID="XTreeView1" runat="server">
From the Property pane you will see a new property category
Sitemap, it has one property Sitemap. Browse and select it. That is it. The following
image shows this.
For more sitemaps repeat the steps listed above.
View the page in browser you will see that all TreeView are
not only successfully bound with their corresponding sitemaps, but also persist
their expansion state.