German Wear Discount Shop - Click Here Write for Dotnet-friends and earn for your each submission [Dot]Net-Friends
Skip Navigation Links
Home
Latest
Fast Code
Articles
Tutorials
Online Resources
Forums
Login   | Hi, Guest


Create a Website Navigation or Menu with SiteMapDataSource & SiteMapPath Controls

Written by omerkamal on Jul 05, 2007
How to add a Navigation bar or a Menu to your Website?

Website Navigation

To make your Website easily accessible a web site menu and its navigation is very important. There is an image view of our website Navigation and Menu.


dotnet-Friends.com Admin Menu

You want to add a Menu or a Navigation bar to your website. In both cases you need SiteMapDataSource. So how to create a SiteMapDataSource ?

  1. Create a new File "WebNav.sitemap" in your Project root directory
  2. Add links of your desired pages to it. it will look like this:  

Xml  version="1.0" encoding="utf-8" ?>

<siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

    <siteMapNode title="Home" url="Default.aspx">

   <siteMapNode title="Forum" url="Forum/ForumMain.aspx">

     <siteMapNode title="Forum Topics" url="Forum/ForumTopics.aspx">

             <siteMapNode title="Thread Messages" url="Forum/ThreadMessages.aspx"/>

             <siteMapNode title="Create Message" url="Members/Reply.aspx"/>

     siteMapNode>   

     <siteMapNode title="Fast Code" url="FastCode/Default.aspx" />

      <siteMapNode title="Articles" url="Articles/Default.aspx" />

      <siteMapNode title="Tutorials" url="Tutorials/Default.aspx" />     

      <siteMapNode title="FamilyData" url="Family/Default.aspx" />

    siteMapNode>

 siteMap>

Title is a Text of the node whereas URL is the path of the page relative to the root directory. Don’t worry about the Family data link. It will only show to those who have the Family Role in your Members.

For reading about Roles Management read Manage Roles in your Web site using ASP .NET 2.0

How to create a SiteMap Provider?

You need to create a Provider to go next. Open your Web.Config File and enter the following line of tag to it. The SiteMap Tag comes inside the Tags.

<system.web>