Wednesday, October 22, 2008

Building a Site Navigation and Site Menu Using ASP.NET Sitemap and SitemapDataSource Control

Building a Site Navigation and Site Menu Using ASP.NET Sitemap and SitemapDataSource Control
How to build sitemap and navigate a site in asp.net


Introduction

With the new framework of ASP.NET 3.5, building a site map for your website is easier. I will cover the demonstration of using the new SiteMapDataSource and TreeView controls.

Main

One of the great advantages of using a site map in the default web.sitemap file is that the file also can be the source of a breadcrumbs navigation. You probably have encountered these navigation on many sites. They list the trail of pages that you have navigated to reach the current page, and you can backtrack through the list by clicking on the listed links. It can simplify your navigation and give a quick view of a web structure. Its purpose is to give users a way to keep track of their location within programs or documents. Example of Breadcrumbs:



Now I am going to show how to create sitemap and navigation. After that, it is easier to add breadcrumbs from toolbox. First you can create a new project and then create a new website. Select asp.net website. After that you can add new item like the one below:

Visual Studio automatically creates the required initial code for web.sitemap and after that I can add a web structure as shown in below example.



<SITEMAP xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<SITEMAPNODE title="Welcome to WorldOfASP.NET" description="WorldOfASP.NET">
<SITEMAPNODE title="About WorldOfASP.NET" description="WorldOfASP.NET" url="About.aspx" />
<SITEMAPNODE title="Contact WorldOfASP.NET" description="WorldOfASP.NET" url="ContactUs.aspx" />
<SITEMAPNODE title="Link to WorldOfASP.NET" description="WorldOfASP.NET" url="LinkToUs.aspx" />
podcast directory
Bloglisting.net - The internets fastest growing blog directory

RSS Feed

Blog Directory & Search engine

Followers

About Me