Click here to Skip to main content
Email Password   helpLost your password?

Introduction

This is a free web based menu (JavaScript enabled) control. There are not many web menu controls available that support dynamic menu creation and binding. This WebMenu control supports dynamic menu creation, XML menu binding and also DataSet binding. This control uses triga (free script) JavaScript menu internally. Any complex menu structure can be represented using a simple XML schema. Menu position and style can be easily applied and changed dynamically without affecting the web application.

Steps to setup WebMenu

  1. Create a new ASP.NET web project, right click on ToolBox; choose 'Add/Remove items' and add the SuperControls.WebMenu.dll reference (compile SuperControls.WebMenu.cproj to get the DLL).
  2. Copy the JS files menu_tpl.js and menu.js to the root directory of the site.
  3. Copy menu stylesheet menu.css file to the subdirectory css.
  4. Copy menudata.xml to the root directory.
  5. Create an ASPX file and drag and drop the WebMenu control to the WebForm and use one of the methods (given below) to bind the XML/dynamic data to the menu control.

ASPX Code

<cc1:WebMenu id="WebMenu1" MenuXMLPath="\\ServerName\rad\menudata.xml" 
                                        PadWidth="24" runat="server">
</cc1:WebMenu>
<!--
Other samples
//**********************************************************************
<cc1:WebMenu id="WebMenu2" MenuXMLPath="ServerName\rad\menudata.xml" 
                      ImageArrow="<img src=images\\arrow.gif border=0" 
                      PadWidth="22" runat="server">
</cc1:WebMenu>
<cc1:WebMenu id="WebMenu3" MenuXMLPath="\\ServerName\rad\menudata.xml" 
                           ImageArrow="" PadWidth="26" runat="server">
</cc1:WebMenu>
-->

Ways of binding menu items dynamically...

Method 1

Set MenuXMLPath property with the path of the XML menu file in the server.

Method 2

Create new DataSet with the XML file and bind to the web menu control.

For example:

       DataSet dsMenu = new DataSet();
       dsMenu.ReadXml(@"\\ServerName\rad\menudata.xml");
       WebMenu1.DataSource = dsMenu;

Method 3

Get the menu data from database and populate the DataSet with the following structure:

For example:

 WebMenu1.DataSource = dsMenu;
 // (Sample DataSet is given below.)

XML menu file (sample)

<?xml version="1.0" encoding="utf-8" ?> 
<menu>
    'Level 0 nodes
    <menuitem root="" name="Search Sites" menuid="1" />
    <menuitem root="" name="Webmail Sites"  menuid="2" />
    <menuitem root="" name="DotNet Sites"  menuid="3" />
    
    'Level 1 Items
    <menuitem root="1" name="Google" url="http://www.google.com" 
                                                        menuid="11"/>
    <menuitem root="1" name="Altavista" url="http://www.Altavista.com" 
                                                        menuid="12"/>
    
    'Level 1 Items
    <menuitem root="2" name="Hot-mail" url=""  menuid="21"/>
        'Level 2 Items
        <menuitem root="21" name="Hotmail" url="http://www.hotmail.com" 
                                                          menuid="211"/>
        <menuitem root="21" name="MSN" url="http://www.MSN.com" 
                                                          menuid="212"/>
        
    <menuitem root="2" name="Yahoo" url="http://www.yahoo.com" 
                                                           menuid="22"/>
    <menuitem root="2" name="Rediff" url="http://www.rediff.com" 
                                                           menuid="23"/>
    
    'Level 1 Items
    <menuitem root="3" name="Microsoft" url="http://www.Microsoft.com" 
                                                           menuid="31"/>
    <menuitem root="3" name="GotDotNet" url="http://www.GotDotNet.com" 
                                                           menuid="32"/>
    <menuitem root="3" name="CodeProject" url="http://www.CodeProject.com" 
                                                           menuid="33"/>
    <menuitem root="3" name="ASpdotnet" url="http://www.ASpdotnet.com" 
                                                           menuid="34"/>
    
</menu>

In the above sample, the root attribute represents the parent of the menu item. The root attribute will be empty for parent/level zero menu items.

Sample dynamic menu DataSet (with one DataTable)

root name menuid url
Search Sites 1
Webmail Sites 2
DotNet Sites 3
1 Google 11 http://www.google.com
1 Altavista 12 http://www.Altavista.com
2 Hot-mail 21
21 Hotmail 211 http://www.hotmail.com
21 MSN 212 http://www.MSN.com
2 Yahoo 22 http://www.yahoo.com
2 Rediff 23 http://www.rediff.com
3 Microsoft 31 http://www.Microsoft.com
3 GotDotNet 32 http://www.GotDotNet.com
3 CodeProject 33 http://www.CodeProject.com
3 ASpdotnet 34 http://www.ASpdotnet.com
You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralMasterPage Error
wallaces528
17:53 29 Nov '09  
It's a great Menu Control, easy to generate Menu from Dataset.

But, when i use MasterPage, i put a Menu1 at MasterPage,
and click one of Menu item, when redirect to target page,
an error occur "Menu1 undefined".

Please help me to solution this exception.
Thanks a lot.
GeneralI cant see the menu
Koval_Prad
5:18 6 Oct '09  
I implemented all of your steps for the Webmenu control i couldn't view the
menu, even when i linked the both JS files at the Html source page(aspx). And in the run time i couldn't see anything menu at all



Thanks & Warm Regards,
M.L.Kovalavarajan
Generalcant see anything
nandakumarse
0:40 2 Jul '09  
hi

i hav iniplemented ur steps i cant see anything in th page ...!!!
plz help us...

regards
Ram
Generalmenus position [modified]
sooberfellow
22:15 30 Jun '09  
I want to set the menus in a td ..

<td colspan="4" bgcolor="#215baf" height="1" align="right" cellspacing="2px" cellpadding="2px"&gt;
<cc1:WebMenu id="WebMenu1"   PadWidth="0" runat="server" /cc1:WebMenu></td>

my 2nd question is about the alignment how can i make it right to left aligment

please mail me..

brainsarif@gmail.com
GeneralOracle connectivity
kvalli
23:32 15 Apr '09  
how to fetch the menus just from the oracle table?
u have given all the menus in xml code..but just giving the format there u have to retrieve it from database..how to do so?
GeneralHow can i set the target frame..
ryanjoseph
15:53 8 Feb '09  
hi..good day..i use your control and it is very cool...but i have 1 question, how can i set the target frame the page will be viewed..please help me it's urgent...thanks in advance...
GeneralMicrosoft JScript runtime error: 'menu' is undefined
Member 1610415
21:14 23 Nov '08  
When i run the code this error comes
<body>
<form id="form1" runat="server">




PadWidth="24" runat="server" />
</form>
</body>
Generalunable to download the zipped file
Member 4206132
19:50 13 Aug '08  
Hi ,
I tried to download the attachment but unable to download and redirects me to the same page .

Please help me.

thanks,
Generalset menu as vertical and horiz
ramakrishna_yl
22:25 18 Nov '07  

Is it possiable to change web menu control as Horz.. and vertical
if we can change let me know
thanks for helping me
GeneralThank u a lot
ramakrishna_yl
1:50 24 Oct '07  

krishna thank u a lot

GeneralSystem.StackOverflowException
ramakrishna_yl
0:50 24 Oct '07  
An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll


i will be thankful if any one help me
i cont understand why this occur
GeneralCan not see anything
alexaz1
10:28 12 Oct '07  
Hi Krishna,

I have followed your instructions but can not see anything. Please help.

Thank you,

Alex
Generalkewl
chullan
21:49 20 Jun '07  
This menu is good, but when .NET is providing a dynamic menu control within itself why should we go for this dll ?? is there any extra advantages for this ?? I am using the .net dynamic menu in my project, which takes dataset or xml file as datasourse, you can place it verticaly as well as horizontaly... it works great.

regards
samSuspicious

Sooraj J.
Junior Research Fellow
Centre for Development of Advanced Computing
Trivandrum

GeneralPlease Inform me
Prapthi
0:17 26 Mar '07  
Hi,

This is really a great article. I have done this job successfully. But, The menu is created in Horizontal direction. I wish to change it to Vertical. how can i do this. please help me.

Thanks,
GeneralGiving ERROR menu is undefined
swapnali.mankar
1:45 16 Mar '07  
hi ...
i am going to use this control first time ...
as the guidelines are provide ..i hav efaloowed all guidlines .

1)create new project .
2)i have copy the two menu js file in solution itself and same for menudata.xml.
3)i create one subdirectory name css in project and copy the menu css
4)included the dll.
5)populate dataset
6)bind dataset to webmenu.
now when i run the page i get the javascript error "menu is undefined"

did i copied the menu.js at right place ?

its in the root dir as you told ...

please rely soon....



gorakh borude.
GeneralRe: Giving ERROR menu is undefined
André FliP
10:28 19 Apr '07  
menudata.xml path is incorrect! on the html of default page you can change this path... use an exact path.

--
andreflip
GeneralRe: Giving ERROR menu is undefined
solrac00
6:24 5 Feb '10  
Do not forget to put this in between the head tags so that the js scripts are found.

<head id="head1" runat="server">
<script src="menu.js" type="text/javascript"></script>
<script src="menu_tpl.js" type="text/javascript"></script>
</head>

thanks...
GeneralTigra Menu
treputt
7:16 2 Mar '07  
Just want to clarify...the most important part of this article is where he says that this control "uses triga (free script) JavaScript menu internally". The name is mispelled. The product is "Tigra Menu". The web page for this free component is:

http://www.softcomplex.com/products/tigra_menu

So the above article is more about extending this free component than actually building the menu. You will want to look at the documentation for the product before implementing the above. The free component does not support some features (several of which are asked about in the questions below - placing the menu in a table, frame problems, etc.). There is a more advanced component that you can purchase that will support these features. It's pretty inexpensive.

Hopefully most picked up on this, but from the questions below, it sounded like a lot of people were in the same boat I was in!

Mike
Questionneed object in menu.js 78 [modified]
hihba
16:42 6 Feb '07  
Hi, I am using web menu on ASP.Net page and on a button submit to the same page, the menu item disappears with error - Line 160 ;char 4; error: Object required.
Same page on loading, menu works fine. Pls help.
thanks,
Rajesh




Jeff_He hba6262.tw@yahoo.com.tw


-- modified at 22:39 Tuesday 13th February, 2007
Joketanx
Juan Carlos Guillén Zurita
6:43 2 Feb '07  
tanx good workRoll eyes

guill@n

GeneralI don't see anything either.
Grondal
2:03 17 Nov '06  
I've also followed all the instructions and don't see anything either...

I guess you get what you pay for...
GeneralDont see anything...
keng1509
18:05 9 Nov '06  
I follow all steps like what you mention in the page. But I cant display anything oh...

If can, can you apply me as soon as possible?

Thanks alot.

From : Nicole
GeneralVertical Menu
csgraham
10:23 17 Oct '06  
This is an excellent control but i was wondering if it was possible to make it vertical i.e, multiple categories up and down the screen and on mouse over sub categoris appear to the left hand side. Any help on this appreciated.


CG
Generaljust want to said thank you
tarikelmallah
10:45 16 Oct '06  
Smilejust want to said thank you

Tarek El-Mallah
.net web application Developer

GeneralUsing different images for each menu?
saeed_amd
23:34 20 Sep '06  
Is there any way to use different images for each menu, say if i want to use images for root elements instead of text, where can i define image property. If i use ImageArrow property then all the menu have same image, can any one help me in this regard.....


Last Updated 22 Sep 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010