In this article I will explain with an example, how to implement BreadCrumbs in ASP.Net using SiteMap and SiteMapPath control.
BreadCrumbs are used for navigation purposes and can be easily implemented without any programming using SiteMap file and the ASP.Net SiteMapPath 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">
</asp:SiteMapPath>
<hr />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
 
 
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.
Implement BreadCrumbs in ASP.Net using SiteMap and SiteMapPath control
 
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="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
 <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>
    <siteMapNode url="About.aspx" title="About" description="About Us Page" />
    <siteMapNode url="Contact.aspx" title="Contact" description="Contact Us Page" />
 </siteMapNode>
</siteMap>
 
 
Screenshot
Implement BreadCrumbs in ASP.Net using SiteMap and SiteMapPath control
 
 
Downloads