Adding Menu Items Programmatically at Application Run-time

You can add menu items to a menu control programmatically at application run-time by customizing the menu control’s code-behind file:

...\Menu Panels\menu.ascx.cs (.vb)

Override the Page_Load method in Section 1 and add this code:

MenuItem item = new MenuItem();

item.Text = "DynamicMenu1";

item.Value = "DynamicMenu1";


Displaying images in menu items in addition to menu item text

You can display an image next to menu item text in a menu control by modifying or adding the imageUrl property in sitemap file.  Each menu item for which an image is to be displayed should have the URL of the image specified in the sitemap file.

<siteMapNode title="{Menu:Add} Categories" description="{Menu:Add} Categories" url="~/Categories/AddCategories.aspx" imageUrl="~/Images/MenuAddRecord.gif" roles="" />

To display only the image and no menu item text, modify the menu control’s code-behind file, located in:

...\Menu Panels\menu.ascx.cs (.vb)

In Section 1, change the ModifyMenuItem() method to include this line:


See Also

Configuring Multi-Level Menus

Specifying Security Roles for Multi-Level Menus

Specifying the Sitemap Provider

Renaming and Deleting Menu Controls

Adding Menu Items Programmatically at Application Run-time

Changing the Application Menu Type from Classic to Multi-level

Improving Multi-Level Menu Performance