ComponentOne WebMenus and WebBars for ASP.NET (2.0) Search HelpCentral 

Adding a Menu Item

This topic demonstrates how to create a menu item using code.

1.   Add a PlaceHolder control to the web page.

2.   Import the C1.Web.Command namespace to your source code.

·      Visual Basic

Imports C1.Web.Command

·      C#

using C1.Web.Command;

·      Delphi

uses C1.Web.Command;

3.   Enter the following code in the Page_Load procedure to create a new menu item:

·      Visual Basic

Dim menu As New C1WebMenu()

·      C#

C1WebMenu menu = new C1WebMenu();

·      Delphi

var

   menu: C1WebMenu;

begin

   item:= C1WebMenu.Create;

4.   Add the C1WebMenu to the PlaceHolder control so it appears once you run the web page.

·      Visual Basic

PlaceHolder1.Controls.Add(menu)

·      C#

PlaceHolder1.Controls.Add(menu);

·      Delphi

PlaceHolder1.Controls.Add(menu);

5.   Add the new item to C1WebMenu. Also add its text and url through the Text and NavigateUrl property. Enter the following code:

·      Visual Basic

Menu.Items.Add(New C1WebMenuItem("ComponentOne", "http://www.ComponentOne.com"))

·      C#

Menu.Items.Add(new C1WebMenuItem("ComponentOne", "http://www.ComponentOne.com"));

·      Delphi

Menu.Items.Add(new C1WebMenuItem('ComponentOne', 'http://www.ComponentOne.com'));

6.   Save and run your web application. You'll have a single menu item that appears like this:

Note: When you click on the menu item, the NavigateUrl property takes you to ComponentOne's web site.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.