C#: SiteMapPath Control
By: Zack Turnbow
Introduction
Most business web sites can have a large footprint, that is, several pages to visit. It can be difficult to navigate through the site with just normal menus. Many companies started creating “bread crumb” trails so that a user will know exactly where they are in the web site. This becomes increasingly difficult when a site keeps adding pages as it evolves. ASP.NET 2.0 solved this issue by introducing the SiteMapPath control.
If you're ever in the market for some great Windows web hosting, try Server Intellect. We have been very pleased with their services and most importantly, technical support.
Implementation
Start fresh with a new web application in Visual Studio. The SiteMapPath control is used in conjunction with a Web.sitemap file. So the first action required is to add a Web.sitemap item to the project.
Before adding anything to the new file, a little explanation and planning needs to take place. The Web.sitemap file is just an XML file that holds the structure of the web site. So it is a good idea to take some time to plan the initial layout of the web site. Below is a basic structure of a typical web site:
Company History
Press Releases
Product 2
Repair Service
Technical Assistance
Forum
Support
Existing Customer
Customer Feedback
We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with!
As shown, the site layout might cause a user (customer) to get lost in the site. So with this lay out in mind, enter the following code into the Web.sitemap file.
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Home.aspx" title="Home" description="Home">
<siteMapNode url="AboutUs.aspx" title="About Us" description="About Us">
<siteMapNode url="Mission.aspx" title="Mission Statement" description="Our Mission Statement" />
<siteMapNode url="History.aspx" title="Company History" description="Our Company History" />
<siteMapNode url="Press.aspx" title="Press Releases" description="Press Releases" />
</siteMapNode>
<siteMapNode url="Products.aspx" title="Products" description="Company Products">
<siteMapNode url="Product1.aspx" title="Product 1" description="Prodcut 1 Information" />
<siteMapNode url="Product2.aspx" title="Product 2" description="Prodcut 2 Information" />
</siteMapNode>
<siteMapNode url="Services.aspx" title="Services and Parts" description="Services and Parts">
<siteMapNode url="Parts.aspx" title="Parts for Sale" description="Parts for Sale" />
<siteMapNode url="Repair.aspx" title="Repair Service" description="Repair Service" />
<siteMapNode url="Technical.aspx" title="Technical Assistance" description="Technical Assistance">
<siteMapNode url="Documentation.aspx" title="Documentation" description="Documentation" />
<siteMapNode url="Forum.aspx" title="Forum" description="Forum" />
<siteMapNode url="Support.aspx" title="Product Support" description="Product Support" />
</siteMapNode>
<siteMapNode url="Sales.aspx" title="Sales" description="Sales">
<siteMapNode url="NewCustomer.aspx" title="New Customer Sales" description="New Customer Sales" />
<siteMapNode url="Customer.aspx" title="Existing Customer Sales" description="Existing Customer Sales" />
<siteMapNode url="Feedback.aspx" title="Customer Feedback" description="Customer Feedback" />
</siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
Each level of the layout above corresponds to an outer node of the Web.sitemap file. For instance, the About Us node is
.
.
.
</siteMapNode>
with the mission statement, history, and press releases nodes being inside the About Us node. This XML file will give an easier way of tracking site navigation and the ability to add, change, or delete pages. Now that the sitemap has been defined, the next step is to create the master page to be the template for each page.
Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.
On the master page, add a SiteMapPath control and a Menu control to the page. Now it is time to create each of the pages listed in the Web.sitemap file. For this article, only the Home, the AboutUs, the Mission, the History, and the Press aspx pages will be created. Make sure to set the master page to the once created above when adding the pages to the project.

Go back to the master page and format the Menu control to have the layout displayed below.
Go to the Home page and a Label on the work area and give the label the name of Home.
****************************
Repeat the steps for the AboutUs, the Mission, the History, and the Press aspx pages. Once this is complete, run the application and navigate the pages using the SiteMapPath control.
This article has shown another option for a user to navigate a web site as well an easy way for the developer to keep track of site navigation.
We chose Server Intellect for its dedicated servers, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.
What have we learned?
How to create a Web.sitemap file to be used in site navigation.
How to create a master page so that all other pages use it as a template.
How to incorporate the SiteMapPath control along with a Menu control to assist in site navigation.
Attachments








Leave a Comment
#1 vijayvardhan`
Posted By: vijayvardhan` | 12.01.2008 at 10:16 AM
it is verygood for the developers.
#2 Amandeep Singh
Posted By: Amandeep Singh | 1.03.2009 at 12:19 AM
thnx your posted help was very good, i got a very good help through it
with regards
aman
#3 Yogesh S
Posted By: Yogesh S | 4.30.2009 at 4:01 AM
It is good but needs more explanation
#4 online games
Posted By: online games | 11.24.2009 at 11:00 PM
it is verygood for the developers.
#5 vivek
Posted By: vivek | 1.07.2010 at 5:30 AM
No any email in my id
#6 vivek
Posted By: vivek | 1.07.2010 at 5:30 AM
Thanks for this code
#7 rizwan
Posted By: rizwan | 1.19.2010 at 9:47 AM
thanks you have solved my problem
great stuff
#8 Gun Safes Sale
Posted By: Gun Safes Sale | 1.26.2010 at 5:13 PM
thnx your posted help was very good, i got a very good help through i
#9 actual exam
Posted By: actual exam | 2.01.2010 at 7:44 AM
Some of the facts regarding sitemath is as follow:
The SiteMapPath control displays a list of links representing the user's current page and the hierarchal path back to the root of the website. This functionality is sometimes referred to as a breadcrumb for the user
The SiteMapPath control relies on a SiteMapProvider to retrieve the data that it will display. Unlike the Menu or Treeview control the SiteMapPath control does NOT use a SiteMapDataSource control and can not be bound to other hierarchal datasource controls.
The default SiteMap provider will automatically be used by the control or you can set the SiteMapProvider property on the control to point to any provider already configured in the web.config file.
#10 portable clothes rack
Posted By: portable clothes rack | 2.04.2010 at 2:41 AM
The SiteMapPath control relies on a SiteMapProvider to retrieve the data that it will display. Unlike the Menu or Treeview control the SiteMapPath control does NOT use a SiteMapDataSource control and can not be bound to other hierarchal datasource controls.
#11 640-802
Posted By: 640-802 | 2.12.2010 at 12:33 AM
Laying out the analytic anatomy of a Web appliance provides a starting point for architecture user interface aeronautics controls. ASP.NET 2.0 simplifies the architecture of such controls with the Website Map Web server ascendancy and accompanying aeronautics controls. The website anatomy is abundant in a website map book and acclimated to abide aeronautics elements. In antecedent versions of ASP.NET, this simple action captivated a block of development time.
#12 350-001
Posted By: 350-001 | 2.12.2010 at 12:34 AM
The website map is the abject for application the aeronautics controls accessible in ASP.NET 2.0. The website map is acclimated as the abstracts antecedent for the aeronautics controls. These aeronautics controls cover Menu, SiteMapPath, and TreeView. Next week, I will accommodate the data of application the SiteMapPath ascendancy with a website map.
#13 VCP-310
Posted By: VCP-310 | 2.12.2010 at 12:35 AM
The System.Web namespace contains the SiteMap class, which corresponds to the ASP.NET website map feature. It is an in-memory representation of the aeronautics anatomy for a site. The chic provides admission to the assorted elements aural a website map. The two a lot of important (or used) backdrop of the chic are CurrentNode and RootNote.
#14 free game
Posted By: free game | 3.07.2010 at 3:30 AM
Hi webmaster, your website's theme is amazing and i like it. Your posts are totally great. Please keep up the good work. Greets!!
#15 cool games
Posted By: cool games | 3.07.2010 at 3:30 AM
Hello, your web page's theme is nice and i like it. Your blog posts are cool. Please keep them coming. Greets..
#16 1Z0-053 question
Posted By: 1Z0-053 question | 3.19.2010 at 5:41 AM
For all I know this could be a really old entry, since there are no date marker on the article. In that case I apologize.