Introduction:
A site map is a graph representing all the pages and
directories in a web site. Site map information shows the logical coordinates
of the page and allows dynamic access of the pages and render all navigational
information in a graphical way. ASP.Net contains a rich navigation
infrastructure which allows the developers to specify the site structure. Since
the site map information is hierarchical in nature, it can be used as input for
a hierarchical data source control such as SiteMapDataSource. The output of a
SiteMapDataSource can be bound to hierarchical data-bound controls such as Menu
or TreeView.
Site Map Basics:
ASP.Net navigation is flexible, configurable, and pluggable.
It consists of three components:
- Definition
of the navigational structure of your site. This is the XML site map,
which is stored in a file.
- Parsing
the site map file and convert its information into a suitable object
model. This part is performed by the SiteMapDataSource control and the
XMLSiteMapProvider.
- Using
the site map information to display the user’s current position and
provide ease of navigation. This part is provided through the controls you
bind to the SiteMapDataSource control, which could be lists, menus or
trees.
You can customize or extend each of these separately. For
example for appearance purpose, you can bind different controls to the
SiteMapDataSource. On the other hand you can create a custom site map provider
to receive information from a database.

Simple Site Map Design:
Let us start with a quick example where the
SiteMapDataSource control passes the site map information to a hierarchical
data-bound control so that it can display the site’s structure.
The following Code shows a simple imaginary site map for an
author’s site:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="mySiteMapDataSource"
runat="server"
/>
</div>
<asp:TreeView ID="mytreeview"
runat="server"
DataSourceID="mySiteMapDataSource"
Height="307px"
Width="173px">
</asp:TreeView>
</form>
</body>
</html>
The SiteMapDataSource is filled by
the following Site map:
<?xml
version="1.0" encoding="utf-8" ?>
<siteMap
xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="Home" description="Hanif-Online Homepage">
<siteMapNode url="" title="Publication" description="Books by the Author">
<siteMapNode url="" title=" Books" description="" />
<siteMapNode url="" title="Projects" description="" />
</siteMapNode>
<siteMapNode url="" title="Examination Support" description="Solved Papers">
<siteMapNode url="" title=" University
Examinations" description="" />
<siteMapNode url="" title="Professional Courses" description="" />
</siteMapNode>
</siteMapNode>