Modify the RedirectURL Property of a Menu

Updated June 5, 2006
Iron Speed Designer V4.0 and later

To dynamically modify the redirect URL of a menu item for a specific page, you can handle the PreRender event for the Menu.ascx control (in Menu.ascx.cs or menu.ascx.vb).  Then you can modify the RedirectUrl property for the specific menu item.  This code for classic menu would look something like:

Me.Menu.Menu1MenuItem.Button.RedirectUrl = "http://...?Session=" & SessionVar

Me.Menu gives you the menu and Menu1MenuItem gives you the first menu item.  You can use Menu2/3/4/etc. for the appropriate menu item in the menu.  Menus are really buttons, so you need to access the button control inside the menu item.  Use the Me.Menu.Button property for this.  Then, set the RedirectUrl for the button (menu).

In the example above, RedirectUrl is set to a URL composed using information stored in a session variable.  However, you can compose the URL in a manner of your choosing.

Please note that you should also set the RedirectUrl for the highlighted version of the menu as well:

Me.Menu.Menu1MenuItemHilited.Button.RedirectUrl = "http://...?Session=" & SessionVar

For multilevel menu you need to use different class :

Me.MultiLevelMenu.Items[0].NavigateUrl = "http://...?Session=" & SessionVar

Where MultilevelMenu.Items is a collection of items, each of them has its own collection as well.

See Also

Part V: Customizing Application Code