ASP.NET Easy Menu - How To use AddItem and RemoveItem

Easy Menu provides two JavaScript functions that can be used to add or remove menu items at client side:

AddItem - has the following syntax:
ob_em_EasyMenuID.AddItem(id, type, innerHTML, icon, url, urlTarget, onClientClick, AutoHideMenu, position)
     · id - The id of the item to add.
     · type - The item type to add (MenuItem, MenuSeparator or any custom defined types).
     · innerHTML - The content of the item to add.
     · icon - Icon to display for the item Optional - will only be used if menu uses icons.
     · url - Url to open when item is clicked Optional.
     · urlTarget - Frame where url is to be opened Optional.
     · onClientClick - Javascript code to execute when item is clicked Optional.
     · AutoHideMenu - If true, the menu will autohide Optional.
     · New! position - The position inside menu where you need to be added Optional.

RemoveItem - method has the following syntax:
ob_em_EasyMenuID.RemoveItem(id)
     · id - The id of the item to remove.

Note:
     - EasyMenuID is the id of the Easy Menu to which we want to add/remove the item.
     - document.getElementById("EasyMenuID").object is the same as ob_em_EasyMenuID.
     - If the specified item type doesn't exist for the current menu, MenuItem will be used by default.



Test adding and removing items to the menu on the right (make sure you enter unique IDs):
Id:
Type:
InnerHTML:
Position:
 
Id:
 



Here is the code for the buttons:
<input type="button" value="Add Item"
     onclick="ob_em_EasyMenu1.AddItem(document.getElementById('add_itemId').value,
                                     document.getElementById('add_itemType').value,
                                    document.getElementById('add_itemInnerHTML').value);"
>
<input type="button" value="Remove Item"
     onclick="ob_em_EasyMenu1.RemoveItem(document.getElementById('remove_itemId').value);">

Se also how to remove all the menu items.

"Your fast turn around and helpful attitude have made me VERY VERY HAPPY. This is SO RARE to find especially with something as complicated as a control suite and one so reasonably priced at that."

Cary Abramoff

obout.com
obout.com Home
News
Easy Menu Home 
Easy Menu Home
Download
Site Map
Compare with Text Menu
Examples - 47
Horizontal - 15
Horizontal 1
Horizontal 2
Horizontal 3
Horizontal 4
Horizontal 5
Horizontal 6
Horizontal 7
Horizontal 8
Horizontal Right To Left
Transparent - over flash
Transparent - over iframe
MSDN
MSDN 2
With rounded corners
Keep Open New
Vertical - 3
Vertical 1
MS Vertical
Vertical Right To Left
ContexMenu - 10
World Map
Default
Futura
VSNET
Windows
WindowsXP
Style 1
Style 2
Style 3
Right To Left
Tab Strip - 20
Tab Strip
Tab Strip - With postback New
Different Styles - 14
TabStrip1
TabStrip2
TabStrip3
TabStrip4
TabStrip5
TabStrip6
TabStrip7
TabStrip8
TabStrip9
TabStrip10
TabStrip11
TabStrip12
Yahoo TabStrip
Parent Child Tabstrip New
Tab Strip - Wizard
Tab Strip - Wizard 2
Add / Remove Tabs
Add / Remove Tabs 2
Time Picker
Features - 46
Fast loading time
Multi Column Menu - 2
Multi Column Submenu New
Multi Column Submenu with Icons New
Multiple menus - 3
Multiple menus
Multiple menus 2
Horizontal menu and Tab Strip
Operations - 9
ShowEvent New
Add / Remove Items New
Hide / Show Items New
Menu item inner HTML New
Attach / Detach
Menu Events
OnClientClick
Menu item postback
Show menu New
Align/Position - 4
Align
Advanced Align
Menu Offsets
Position
Integration  - 13
TreeView - 5
Attach to TreeView
Dynamic Loading
Inside callback panel
Select the TreeView node New
TreeView inside Easy Menu
AJAX Page - 3
Inside AJAX Page panel
Inside MS AJAX panel
Add items server side
Grid - 2
Use With Grid
Inside DataGrid column
Inside WindowNew
Build from SiteMap
Over Java Applet New
Other features - 15
AttachTo
Menu Icons
Menu Customize
Long vertical menus
Long menu items
Disabled menu item
Sub-menus
Custom Menu Items
Using Database
Postback Persistance
Dynamic Easy Menu Item
Full Easy Menu width
Hide menu with time delay
Custom sliding effect New
Custom Menu Content New
Knowledge Base - 2
Knowledge Base
Documentation - 4
Server side
Client side
Using the correct path
ChangeLog