Bind to Multiple ASP.NET Site Map files

You can use more than one sitemap file and decide which one to bind to a control. Follow these steps to bind a control like the Menu Control, to multiple ASP.NET Site Map files. Here I am assuming that you have two SiteMap files – Web.sitemap and Web2.sitemap

1. Define an entry in the web.config as following to make use of the siteMap element:

Multiple Sitemap

2. Now assuming your Menu control is bound to the SiteMapDataSource in the following way:

Sitemapdatasource

3. Now just set the SiteMapProvider property of the SiteMapDataSource to the provider's name from the web.config file, as shown below:

SiteMap1.SiteMapProvider = "providertwo";

That’s it! Your menu control will be bound to the providertwo now.



Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

No comments: