ComponentOne Menu for ASP.NET Web Forms
Task-Based Help / Adding a Top-Level Item to a Menu
In This Topic
    Adding a Top-Level Item to a Menu
    In This Topic

    This topic illustrates how to add a top-level menu item to a C1Menu control in Design view, in Source view, and in code.

    In Design View

    Complete the following steps:

    1. Click the smart tag to open the C1Menu Tasks menu. Select Edit Menu.
      The C1Menu Designer Form dialog box opens.
    2. Click the Add Child Item button  to add a C1MenuItem to the C1Menu control.
    3. Click OK to close the C1Menu Design Form dialog box.

    In Source View

    Add the following markup between the <cc1:C1Menu> tags:

    To write code in Source View

    <cc1:C1MenuItem ID="MenuItem1" runat="server" Text="LinkItem1">    
    </cc1:C1MenuItem>

    In Code View

    Complete the following steps:

    1. Import the following namespace into your project:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Web.Wijmo.Controls.C1Menu
      

      To write code in C#

      C#
      Copy Code
      using C1.Web.Wijmo.Controls.C1Menu;
      
    2. Add the following code to the Page_Load event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim MenuItem1 As New C1MenuItem()
      C1MenuItem1.Text = "LinkItem1"
      C1Menu1.Items.Add(C1MenuItem1)
      

      To write code in C#

      C#
      Copy Code
      C1MenuItem MenuItem1 = new C1MenuItem();
      C1MenuItem1.Text = "LinkItem1";
      C1Menu1.Items.Add(C1MenuItem1);
      
    3. Run the program.