SiteMapDataSource Control in ASP.Net

SiteMapDataSource Control in ASP.Net

The SiteMapDataSource control enables you to declaratively data-bind to site navigation data in your pages. The SiteMapDataSource control is used as a data source to place a site map on the website. A site map is a way to present all folders and pages of the website. The site map information can appear in many forms. SiteMapDataSource control is used generally as a data source for asp: SiteMapPath control.

Some Important Properties of SiteMapDataSource Control:

Sitemap Provider

Gets or sets the name of the site map provider. This information is written on web.config file.


Used to set the URL in the sitemap that will be considered as root.


True/false. Whether to show starting node or not.


<asp:Repeater ID='Repeater1' runat='server' DataSourceID='SiteMapDataSource1'>
<asp:SiteMapDataSource StartingNodeUrl='~/home.aspx' ID='SiteMapDataSource1' runat='server' />
<asp:SiteMapPath ID='SiteMapPath1' runat='server'/>

 Here StartingNodeUrl is '~/home.aspx' site map Node will be started from Home

SiteMapDataSource Control in ASP.Net


<siteMap xmlns='net' >
  <siteMapNode url='home.aspx'title='Home'  description='Home'>
   <siteMapNode url='database.aspx'title='Database'  description='Database'>
     <siteMapNode url='sqlserver.aspx'title='SqlServer'description='Sql'/>
     <siteMapNode url='mysql.aspx'title='My Sql'  description='My Sql' />
    <siteMapNode url='script.aspx'title='Scripting Language'  description='Scripting Language' >
      <siteMapNode url='javascript.aspx'title='java script'  description='Java script' />
      <siteMapNode url='vbscript.aspx'title='vb script'  description='1' />

 Here home.aspx is the parent node of database.aspx and script.aspx. sqlserver.aspx & mysql.aspxare child node of database.aspx. javascript.aspx and vbscript.aspx are the child node of script.aspx


<asp:HyperLink ID='HyperLink1' runat='server' NavigateUrl='~/database.aspx'>Database</asp:HyperLink>
<asp:HyperLink ID='HyperLink4' runat='server' NavigateUrl='~/script.aspx'>Scripting language</asp:HyperLink>

When add Database.aspx Script.aspx page then select sitemap.master


<asp:HyperLink ID='HyperLink1' runat='server' NavigateUrl='~/sqlserver.aspx'>SqlServer</asp:HyperLink>
 <asp:HyperLink ID='HyperLink2' runat='server' NavigateUrl='~/mysql.aspx'>MySql</asp:HyperLink>


<asp:HyperLink ID='HyperLink1' runat='server' NavigateUrl='~/javascript.aspx'>Java Script</asp:HyperLink>
<asp:HyperLink ID='HyperLink2' runat='server' NavigateUrl='~/vbscript.aspx'>VB Script</asp:HyperLink>

 Run the project

Now site map path will show on the page

SiteMapDataSource Control in ASP.Net

SiteMapDataSource Control in ASP.Net

Last updated:1/17/2020 5:20:15 AM


Leave Comment