Click here to Skip to main content
Licence CPOL
First Posted 14 Jun 2008
Views 12,247
Downloads 145
Bookmarked 15 times

Using More than One SiteMapPath in a Single Web Project

By | 16 Mar 2010 | Article
There are situations when we want to break a single web project into two or more different projects, there are two or more home pages, two or more master pages, and all have their child pages. In this case, we want two or more SiteMapPath files.

Introduction

Generally we use a single Web.SiteMapPath file in a Web Project and this works as a default SiteMapPath file for whole project. We don't need to give any reference of it to <asp:SiteMapPath> tag. But there are situations when we want to break a single web project into two or more different projects, there are two or more home pages, two or more master pages, and all have their child pages. In this case, we want two or more SiteMapPath files, because each SiteMapPath file can have a single root. That’s because we cannot adjust all partitions SiteMap details into a single SiteMapPath file. This requires the use of ‘SiteMapPathProvider’ property of <asp:SiteMapPath> tag and some configuration setting in Web.Config file of that Web Project.

Using the Code

In the figure above, there’s a Web Project namely WebExample2. This web project has two folders for two different parts (Website1 and Website2) of web project. See there are two master pages and two .sitemap files.

In this case, we need to do some configuration setting in the web.config file of this web project. We must have to add this set of code in <system.web> block.

 <siteMap defaultProvider="W1">
     <providers>
         <add name="W1" type="System.Web.XmlSiteMapProvider" 
		siteMapFile="~/Website1/Web1.sitemap"/>
         <add name="W2" type="System.Web.XmlSiteMapProvider" 
		siteMapFile="~/Website2/Web2.sitemap"/>
     </providers>
 </siteMap>

Now, we have to use <asp:sitemappath> tag this way:

In Web1.Master:

<asp:SiteMapPath ID="siteMap1" SiteMapProvider="W1" runat="server"/>

In Web2.Master:

<asp:SiteMapPath ID="siteMap2" SiteMapProvider="W2" runat="server"/>

Using this method, we can use more than one SiteMapPath in a single web project.

Final Words

I hope you will find this article helpful. For more information, you can check out the demo program available in the downloads section or you can contact me at arshad@cherisys.com. Good luck!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mohd Arshad (Sam)

Software Developer (Senior)
Cherisys Technologies, WebStreet.in
India India

Member

Follow on Twitter Follow on Twitter

Software professional with demonstrated strength in windows-based and web-based software development. Have 4 years of experience with the full software development lifecycle including requirements, design, development, testing/QA, deployment, training & support. Have 1 year experience managing groups, planning and executing implementations. Practical working knowledge of all aspects of IT. Possess strong insight into practical business considerations.



www.cherisys.com
www.webstreet.in
www.codevdo.com
www.bizkut.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralNice job done Pinmemberpamperghost1:58 3 Apr '10  
GeneralMy vote of 1 PinmemberSyed Javed18:29 20 Jan '10  
GeneralRe: My vote of 1 PinmemberMohd Arshad (Sam)4:51 24 Mar '10  
GeneralRe: My vote of 1 PinmemberMohd Arshad (Sam)13:58 31 Mar '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 16 Mar 2010
Article Copyright 2008 by Mohd Arshad (Sam)
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid