.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT
Sandeep Singh

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Simple way to create Dynamic Menu in Asp.net

Posted By:Nikhil Kumar       Posted Date: January 13, 2010    Points: 25    Category: ASP.NET    URL: http://www.dotnetspark.com  

Dynamic Menu control is very useful in asp.net these are menu which you can see on every site, by menu control you can navigate from one page to another page, And its very easy and simple.

Dynamic Menu Control in ASP.NET

Here i will show you step by step procedure how to use Dynamic Menu Control in ASP.NET in visual studio 2005 / 2008

Dynamic Menu control is very useful in asp.net these are menu which you can see on every site, by menu control you can navigate from one page to another page.

Here I am using Visual Studio 2008 but there is no condition you can use Visual Studio 2005 also.
So follow these steps to create Dynamic Menu Control
The Steps are:

1- Start -> All Programs -> Visual Studio 2005 or Visual Studio 2008

2- Now go to File Menu -> New -> Web Site

3- Under Visual Studio Installed Template-> Choose ASP.NET WEB SITE -> Choose File System from the location combo box -> Set the path by the browse button - > Choose the language from the Language ComboBox (Visual C# , Visual Basic , J #)
Choose Visual C#

4 - Click on the OK Button:-

First you have to learn XML and HTML to work with ASP .NET_

I have used to make the text as comment this is the way to make comment in this code .

This is the Source Code window and in this page you will se this code.


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

Type your webpage title here  

See here is a tab named Design in the bottom of this page

5- Click on this tab and you will see a blank web page where you can drag any control from the toolbox (which is in the left side of this window)
Open Web.config file and write true in place of false, See

6- Drag a Menu Control from the navigation control tab

7-Now go in solution explorer and right click on the website and choose Add new item, select XML file
now again choose Add new item, select site Map .
8- Now open XML file and type this code in this.



9- Now open your site Map file and type this code in it.


10- In Design mode select menu control and click on the arrow (seems when you move cursor on menu control)
Choose Data Source -> choose XML or Site Map Data Source

11 - Now run your web site by Ctrl + F5


12-Menu Bar would seem like this


13- Close web browser

14-Close visual studio

--Nikhil Kumar

 Subscribe to Articles


Further Readings:

Author: Rahul         Company URL: http://www.dotnetspark.com
Posted Date: September 24, 2011

Hello Nikhil Kumar,

The tutorial is helpful thanks .But i have a small query. The menu option tutorial you have showed can only be applied to 1 menu i mean . I want like (Galleries,Members and Maps) menu where i highlight on galleries and it should show me the list of images(drop dwn list), so for each and every menu do, i have to create new xml file or sitemap. Iam a fresher in this . Help needed .Thanks in advance.

Author: Nikhil Kumar         Company URL: http://www.dotnetspark.com
Posted Date: September 24, 2011

Rahul, for your requirement no need to do such hard work just use this and enjoy what you want.

css3 menu. just googled it.

Nikhil Kumar
Author: Rahul         Company URL: http://www.dotnetspark.com
Posted Date: September 29, 2011

Hi Nikhil,

Please help me out in this .
I have created a sitemap for Menu (Department) and its working fine, but when i create a new sitemap and use MENU option why i get the same Department items only
Eg: I have created the Departments sitemap below is the codes :

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="Departments.aspx" title="Departments" description="Departments">
<siteMapNode title="Country Manager" description="This will show Details">
<siteMapNode url="Budget.aspx" title="Budget" description="Budget"/>
<siteMapNode url ="Economic Development and Tourism.aspx" title ="Economic Development and Tourism" description="Economic Development and Tourism"/>


<siteMapNode title="Conservation and Compliance" description="Conservation and Compliance">
<siteMapNode url="Conservation and Compliance.aspx" description="Conservation and Compliance"/>
<siteMapNode url="Animal Services.aspx" title="Animal Services" description="Animal Services" />
<siteMapNode url="Code Enforcement.aspx" title="Code Enforcement" description="Code Enforcement" />
<siteMapNode url="Fleet Management.aspx" title="Fleet Management" description="Fleet Management" />

<siteMapNode title="Community Services " description="Community Services ">
<siteMapNode url="Community Services .aspx" description="Community Services "/>
<siteMapNode url="Health and Human Services.aspx" title="Health and Human Services" description="Health and Human Services" />
<siteMapNode url="Housing Services.aspx" title="Housing Services" description="Housing Services" />


Till here it is working fine and when i create a new sitemap for menu (PRODUCT) and choose newdatasource and when i excute it, i still get the department menu option only . Why is it !! Please help me ...Thanks


Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend