Intersoft WebDesktop Documentation
Add new MenuItem at Client Side
See Also Send Feedback
Intersoft WebDesktop > WebMenu > Tutorials > Add new MenuItem at Client Side

Glossary Item Box

Objectives

This tutorial provides a step-by-step guidance on how to add new MenuItem via Client side.

  1. Drag WebMenu and HTML Button from Toolbox into a WebForm page. Named the HTML button "Add MenuItem"
  2. Refer to Working with MenuItem Types Tutorial for configuring MenuItems.

     

  3. In the client-side, add the following codes:
    Script Copy Code
    <script language="javascript" type="text/javascript">   
    function AddMenu()
    {        
       var menuBar = ISGetObject("WebMenuBar1");        
       var menuItem1 = new WebMenuItem();        
       var menuItem2 = new WebMenuItem();               
        
       menuItem1.Name = "mnuSave";        
       menuItem1.ImageURL = "../../images/save.gif";        
       menuItem1.Text = "Save";        
       menuItem1.Enabled = true;               
    
       menuItem2.Name = "mnuSaveAll";        
       menuItem2.ImageURL = "../../images/saveall.gif";        
       menuItem2.Text = "Save All";        
       menuItem2.Enabled = true;               
    
       menuBar.Menus[0].Menu.Items.Add(menuItem1);        
       menuBar.Menus[0].Menu.Items.Add(menuItem2);        
       alert("MenuItem Save and SaveAll have been added");                      
    
       document.getElementById("Button1").disabled = "disabled";
    }
    </script>
    

  4. Invoke AddMenu() function from the HTML button's onclick event.

    Script Copy Code
    <input id="Button1" type="button" value="Add MenuItem" onclick="AddMenu()"/>
    

  5. Run the Project and you will notice that in the File Menu, there are only 2 MenuItems which are New and Open.

     

  6. Click the "Add MenuItem" button and it will display an Alert box.



  7. Click the File Menu and you will see that MenuItems Save and Save all have been added, and "Add MenuItem" button has been disabled.

See Also

© 2012 Intersoft Solutions Corp. All Rights Reserved.