ComponentOne Menu for ASP.NET Web Forms
Task-Based Help / Creating a C1Menu Control in Code
In This Topic
    Creating a C1Menu Control in Code
    In This Topic

    Creating a C1Menu control in code is an easy process. In this topic, you will add a PlaceHolder control to the page, add an import statement, add the C1Menu control, and add the control to the PlaceHolder.

    Complete the following steps:

    1. In Design View, navigate to the Visual Studio Toolbox and add a PlaceHolder control to the page.
    2. Double-click the page to add a Page_Load event and switch to Code view.
    3. Add the following statement to the top of the Code Editor to import the appropriate namespace.

      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;
      
    4. Add the following code to create the C1Menu control and add the control to the PlaceHolder.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      'Create a new C1Menu control
      Dim C1M As New C1Menu()
      'Add C1Menu to the PlaceHolder control
      PlaceHolder1.Controls.Add(C1M)
      

      To write code in C#

      C#
      Copy Code
      //Create a new C1Menu control
      C1Menu C1M = new C1Menu();
      //Add C1Menu to the PlaceHolder control
      PlaceHolder1.Controls.Add(C1M);
      
    5. Press F5 to run your program. You have created a basic C1Menu control in code.