In this article I will explain a tutorial with an example, how to use the SiteMapPath control in ASP.Net.
The SiteMapPath control is used for displaying paths of pages dynamically from the SiteMap file using the SiteMapDataSource control.
HTML Markup
Below is the HTML Markup of the Master Page Main.Master that contains the SiteMapPath control as well as the SiteMapDataSource control.
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="true" />
<asp:SiteMapPath ID="SiteMapPath1" runat="server" PathSeparator=" > " RenderCurrentNodeAsLink="false">
<hr />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
Adding the Sitemap XML and understanding its use
Sitemap is nothing but a map of your site, it is an XML file which has all the Pages and the Child Pages present in the site. Whenever a new page has to be added to your site, you simply need to add its node in the sitemap XML file and the ASP.Net SiteMapDataSource control will automatically grab and display it.
Sitemap can be added using Add New Item Dialog of Visual Studio as shown below.
SiteMapPath control Tutorial with example in ASP.Net
Once the file is added you need to structure it based on the Level 1 Pages and the Child Pages.
Below is the sitemap I am using for this article, it has the following page structure.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="" >
 <siteMapNode url="Home.aspx" title="Home" description="Home Page" >
    <siteMapNode url="Services.aspx" title="Services" description="Services Page">
      <siteMapNode url ="Consulting.aspx" title="Consulting" description="Consulting Page"></siteMapNode>
      <siteMapNode url ="Outsourcing.aspx" title="Outsourcing" description="Outsourcing Page"></siteMapNode>
    <siteMapNode url="About.aspx" title="About" description="About Us Page" />
    <siteMapNode url="Contact.aspx" title="Contact" description="Contact Us Page" />
SiteMapPath control Tutorial with example in ASP.Net