Discusses the benefits and uses of the Site Map in the ASP.NET framework. The Site Map is a hierarchical listing of web pages on your web site. This information is listed inside the Web.sitemap file in an XML format that can be displayed on any aspx page with the correct controls.

In this tutorial, we will discuss the benefits and uses of the Site Map in the ASP.NET framework. The Site Map is a hierarchical listing of web pages on your web site. This information is listed inside the Web.sitemap file in an XML format that can be displayed on any aspx page with the correct controls.

First you can open a Web Application in Visual Studio 2008. Now add a new Item and choose the Site Map. Visual Studio will automatically name it Web.sitemap and start a few siteMap nodes for you as seen below.

Notice the XML declaration at the top of the file. Every node must be listed inside of the parent tags. Inside of the tags you can list as many tags as you’d like as well as nest them if necessary.

In general the Site Map must consist of internal URLs, if it does contain external URLs settings must be adjusted for it to be visible to the end user.

Now that our Site Map has been created, we need a way to display it to the web site visitor. ASP.NET contains several controls to display the Site Map. We can first start out with the most basic control by using the tag. An example is listed below.

This will display a nested horizontal output with the current page listed farthest to the right followed by each parent to its left. It should look something along the lines of Home > Directory Listing > John Smith. Each node except the current page will be hyperlinked.

I’ll list a few more advanced controls below.

Notice the tag is referenced in each of the following controls. It is necessary to display the Site Map with those controls. The control displays the parent node at the top with each child in hideable DIVs below it. The control horizontally hides each child node until the visitor hovers over its parent node. This control has several attributes which will prevent the child nodes from being hidden so that the visitor doesn’t have to hover over the parent node first. Obviously each node with the exception of the current page hyperlinks to itself.

These are the basics on how to use the ASP.NET Site Map abilities. The Web.sitemap file can be located in other directories, but must be referenced if used. You can also add nodes to the Site Map without editing the Web.sitemap file with C# or VB.NET programming.

Download Source Files