Web Site Navigation Using a SiteMap - Adding a SiteMap to the site
(Page 2 of 4 )
After highlighting the project, right click to access the drop-down menu. Click on Add New Item... which brings up the following window.

When you highlight the SiteMap icon you will find Web.sitemap as the name of the file. If you click on the Add button this file will be added to your site as shown. Before clicking the Add button you may choose a name of your own, but do not change the extension. Extensions such as *.sitemap and *.config are protected by ASP.NET for security reasons.

Site structure is in an XML file
Web.sitemap is an XML file with a special structure. It comes with a default template for a folder and a folder/file structure with three attributes, URL, Title, and Description as shown. In a rendered page these can be seen in the address bar, item's control name, and a tool-tip text showing the description.

Here <siteMap/> is the root and it has <siteMapNode/> children. These children represent the folder. These children also contain children which are the files in the folder. As shown here, the default that is added has three <siteMapNodes/> which can be used to represent one folder and two files in the folder.

The SiteMap XML file has been modified to reflect the folder structure shown earlier, as shown in the next picture. Only the structure of the ColdFusionMX61 folder has been partially implemented in this file. Also shown is the provision made for the MSAccess Folder to contain the files DAP.aspx and Ado.aspx. It must be remembered that all the ASPX files will be ContentHolder files (refer to the Master Page tutorial). The title, URL and description values for both the ColdFusionMX61 folder and the file it contains have been added to the declaration. The comments should help in identifying these attributes.

Add the structure of the MSAccess folder along the same lines. Make use of intellisense at every step as shown. This will add to the correctness of the formatting.

The completed Web.sitemap file is shown in the next paragraph.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<!--Home Page--> <siteMapNode url="~/Default.aspx"
title="Home"
description="Home Page"> <!--ColdFusionMX61 Folder &
Contents--> <-- Folder --> <siteMapNode title="ColdFusionMX61"
url="~/ColdFusionMX61/Default.aspx"
Description="CFMX Tutorials"> <-- File -->
<siteMapNode url="~/ColdFusionMX61/Coldfusion.aspx"
title="CFMX"
description="All tutorials on CFMX" />
</siteMapNode> <!--MS Access Folder & Files--> <-- Folder -->
<siteMapNode title="MSAccess"
url="~/MSAccess/Default.aspx"
description="MS Access 2003 related">
<-- Two Files --> <siteMapNode title="ActiveXDataObjects"
url="~/MSAccess/Ado.aspx"
description="Using MS Access Application"/>
<siteMapNode title="Data Access Pages"
url="~/MSAccess/DAP.aspx"
description="Enabling for the web"/>
</siteMapNode>
</siteMapNode>
</siteMap>
Next: Site Navigation with Menu Control >>
More .NET Articles
More By Jayaram Krishnaswamy