Implementing SiteMap In ASP.NET

In this article you will learn about SiteMap implementation.

  1. Create a new ASP.NET Empty Web Application,

    new

    new

  2. Add a new Web Form named Home.aspx,

    Home

  3. Add new Web Form named ProductGroups.aspx,

    ProductGroups

  4. Add a new Web Form named PlasticItems.aspx,

    PlasticItems

  5. Add a new Web Form named Furniture.aspx

    Furniture

  6. Add a new Web Form named AboutUs.aspx

    AboutUs

  7. Add a new Web Form named ContactUs.aspx,

    ContactUs

    Till now, we added the following WebForm files,

    1. AboutUs.aspx
    2. ContactUs.aspx
    3. Furnitures.aspx
    4. Home.aspx
    5. PlasticItems.aspx
    6. ProductGroups.aspx

  8. Add Sitemap file. Right click on Project and select,

    Sitemap
     
  9. Double on Web.sitemap file type the following code:
    1. <?xmlversionxmlversion="1.0"encoding="utf-8" ?>  
    2.     <siteMapxmlnssiteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">  
    3.   
    4.         <siteMapNodeurlsiteMapNodeurl="Home.aspx" title="Home" description="Home Page">  
    5.   
    6.             <siteMapNodeurlsiteMapNodeurl="ProductGroups.aspx" title="Product Group" description="Product Group Page">  
    7.                 <siteMapNodeurlsiteMapNodeurl="Furnitures.aspx" title="Furnitures" description="Furniture Items Page" />  
    8.                 <siteMapNodeurlsiteMapNodeurl="PlasticItems.aspx" title="Plastics" description="Plastic Items Page" />  
    9.                 </siteMapNode>  
    10.   
    11.                 <siteMapNodeurlsiteMapNodeurl="Aboutus.aspx" title="About Us" description="About Us Page" />  
    12.                 <siteMapNodeurlsiteMapNodeurl="Contactus.aspx" title="Contact Us" description="Contact Us Page" />  
    13.   
    14.         </siteMapNode>  
    15. </siteMap>  
  10. Explanation of Web.sitemap code

    Web.sitemap is XML base file.

    In this file there is one main SiteMapNode that is HOME - Home.aspx. Under that we have the following two sections :

    1. ProductGroup section -- (ProductGroups.aspx) having following child link:

    a.    Furniture.aspx
    b.    PlasticItems.aspx

    2. Two Independent Page.

    a.    AboutUs.aspx
    b.    ContactUs.apx

  11. Now, Drag and Drop the SiteMapPath control from ToolBox inside Navigation group,
    Inside following files,

    1. AboutUs.aspx
    2. ContactUs.aspx
    3. Furnitures.aspx
    4. Home.aspx
    5. PlasticItems.aspx
    6. ProductGroups.aspx

    navigation

    Write some sample text in every page:

    PAGE NAME SAMPLE TEXT
    AboutUs.aspx : This is About Us detail page.
    ContactUs.aspx This is Contact Us detail page.
    Furnitures.aspx This is Furnituresdetail page.
    Home.aspx This is Home detail page.
    PlasticItems.aspx This is Plastic Items detail page.
    ProductGroups.aspx This is Product Groups detail page.

  12. Now run application. I had typed Furniture.aspx in address bar.

    address 

    You can see furnitures.aspx page shown. You came here via Home, Product Group, Furnitures. That’s sitemap!. Next article I will explain TreeView and Menu.


Similar Articles