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.
Imports C1.Web.Command
• C#
using C1.Web.Command;
3. Enter the following code in the Page_Load procedure to create a new menu item:
Dim menu As New C1WebMenu()
• C#
C1WebMenu menu = new C1WebMenu();
4. Add the C1WebMenu to the PlaceHolder control so it appears once you run the Web page.
PlaceHolder1.Controls.Add(menu)
• C#
5. Add the new item to C1WebMenu. Also add its text and url through the Text and NavigateUrl property. Enter the following code:
Menu.Items.Add(New C1WebMenuItem("ComponentOne", "http://www.ComponentOne.com"))
• C#
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.
|