Click here to Skip to main content
Licence 
First Posted 30 Sep 2005
Views 39,176
Bookmarked 37 times

Construct and display dynamic unlimited levels of menu

By | 3 Oct 2005 | Article
This article provides developers and non-developers with a module that builds and displays dynamic unlimited levels of menu [English and Arabic].

Introduction

This code is a .NET project that when installed will provide you with three web pages: the first allows you to construct your menu using a tree view as Windows Explorer, you can create unlimited submenus; the second page displays the menu in a left to right manner for an English web site; and the third page displays the menu in a right to left manner for Arabic sites. Now a web site developer need not worry about menus. Just use the first page to construct the menu online, and use one of the other pages to display a menu from the database. They can now create and display menus with unlimited submenus. This module contains JavaScript and CSS code copyright to Bluegrass Technologies.

Using the code

Requirements

Your machine should have:

  1. .NET Framework v 1.1
  2. SQL Server 2000
  3. IIS 5.0

Steps

  1. Run the file webcontrol/iewebcon.msi.
  2. Run file setup.exe (websetup1/debug/setup.exe).
  3. Run the script file dbscript.sql in your SQL Server to create a table menu.
  4. Make the authentication in your SQL Server mixed.
  5. Change the connection string to that for your SQL Server in the file data/sqlconnection.txt.
  6. It will create an application in your IIS called dynamicmenu.

You will find three pages in the application:

  1. english.aspx to display the left to right menu.

  2. arabic.aspx to display the right to left menu.

  3. menuadmin.aspx to construct your menu.

Note: the table menu contains some items, you can remove them.

How to construct a menu

  1. Go to http://localhost/dynamicmenu.aspx.
  2. You will find a tree with a node called menu selected.
  3. Write name and URL of the menu item and press Add, the item will be created and selected.
  4. Select the node where you want to add the menu and repeat step 3.

How to delete a menu item

You are not allowed to delete an item from the database. But alternatively you can make it hidden or visible by selecting it and pressing the appropriate button.

Note: the menu item will be hidden from the English or Arabic display not from the menu admin tree.

How to change display settings

In the file res/css/english.css or arabic.css, you can change the width of the menu, the image of the arrow, and the color settings.

//////Arabic.aspx///////////////////
ul
{
    width: 230px; ////////width of the menu
    border: solid 1px #cccc99;
    border-top: solid 5px #cccc99;
    border-left: solid 2px #cccc99;
    padding: 0px;
}

li ul
{
    display: none;
    position: absolute;
    margin-right: 260px; //// should be 2*width-5
    margin-top: -30px;
}
////////////////////english.aspx///////////////
ul
{
    width: 230px; //////width of the menu
    border: solid 1px #cccc99;
    border-top: solid 5px #cccc99;
    border-right: solid 2px #cccc99;
    padding: 0px;
}

li ul
{
    display: none;
    position: absolute;
    margin-left: 225px;///////should be width-5
    margin-top: -25px;
}
///////////////////////////////////////////////

In the display page, you will find the stylesheet to change the font, color and hover of the menu.

Points of Interest

I think that the added value is the ability to display unlimited subitems of the menu from the database using recursive functions, and to provide a tree view to build the menu.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Abdelmoniem Hafez

Web Developer

Egypt Egypt

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralArabic text in aspx Pinmemberalasaadi18:52 29 Oct '06  
GeneralNot working in Fire Fox Pinmembertuannq0:07 29 May '06  
GeneralI like your menu control like Windows Explorer PinmemberLi Xiaojian(China)22:34 21 May '06  
like title
GeneralRedundency Pinmembermalharone4:49 12 Nov '05  
GeneralRe: Redundency PinmemberBahadir Cambel11:58 28 Dec '05  
GeneralRe: Redundency PinmemberBahadir Cambel13:08 28 Dec '05  
GeneralRe: Redundency Pinmembermalharone16:40 28 Dec '05  
GeneralI like your menu system PinmemberIPhibbs1:09 8 Oct '05  
GeneralRe: I like your menu system Pinmembergxdata19:34 20 Oct '05  
GeneralTree view of the entire solution Pinmembersachinkalse21:38 3 Oct '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 3 Oct 2005
Article Copyright 2005 by Abdelmoniem Hafez
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid