Intersoft Support Center

Create WebMenu Programmatically in Server-side

WebMenuBar can be created programmatically from server-side.

This topic will show you how to create WebMenuBar's structure programmatically in server-side.

To create WebMenu programmatically in server-side

  1. Place the following code in Page_Load to create WebMenuBar's structure.
    C# Copy Code
    protected void Page_Load(object sender, EventArgs e)
       // programmatically create command and items
       MenuCommand cmdFile = new MenuCommand();
       cmdFile.Name = "cmdFile";
       cmdFile.AccessKey = "F";
       cmdFile.Text = "File";
       WebMenuItem itmNew = new WebMenuItem();
       itmNew.Name = "itmNew";
       itmNew.Text = "New";
       WebMenuItem itmNewWindow = new WebMenuItem();
       itmNewWindow.Name = "itmNewWindow";
       itmNewWindow.Text = "New Window";
       WebMenuItem itmNewTab = new WebMenuItem();
       itmNewTab.Name = "itmNewTab";
       itmNewTab.Text = "New Tab";
       WebMenuItem separator = new WebMenuItem();
       separator.Type = MenuItemType.Separator;
       cmdFile.Items.Add(new WebMenuItem("Open"));
       cmdFile.Items.Add(new WebMenuItem("Save", "mnuSave", "../Images/Save.gif"));
       cmdFile.Items.Add(new WebMenuItem("Exit", "mnuExit", "", "e"));

  2. Run the project.
Previous Next