Version

Disabling Menu Items

WebDataMenu™ allows individual items to be disabled. For instance, you may want the end-users not to select or activate certain menu items. You can achieve this functionality by setting the NavItem object’s Enabled property.

To disable individual menu items :

  1. Place a ScriptManger component and a WebDataMenu control on the WebForm.

  2. Add items to WebDataMenu as shown in the Getting Started with WebDataMenu topic.

  3. Select the Paste item under Edit item and set its Enabled property under Behavior to False. You can do this either in the mark-up or set the property in the back-end code.

In HTML:

    <ig:WebDataMenu ID="WebDataMenu1" runat="server">
        <Items>
            <ig:DataMenuItem Text="File" Key="File">
                <Items>
                    <ig:DataMenuItem Text="New">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Open">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Save">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Exit">
                    </ig:DataMenuItem>
                </Items>
            </ig:DataMenuItem>
            <ig:DataMenuItem Text="Edit" Key="Edit">
                <Items>
                    <ig:DataMenuItem Text="Cut">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Copy">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Paste" Key="Paste" Enabled=">
                    </ig:DataMenuItem>
                    <ig:DataMenuItem Text="Select All">
                    </ig:DataMenuItem>
                </Items>
            </ig:DataMenuItem>
        </Items>
    </ig:WebDataMenu>

In C#:

WebDataMenu1.Items.FindDataMenuItemByKey("Edit").Items.FindDataMenuItemByKey("Paste").Enabled = false;

In Visual Basic:

WebDataMenu1.Items.FindDataMenuItemByKey("Edit").Items.FindDataMenuItemByKey("Paste").Enabled = False;
  1. Save and run your application. You will observe that the Edit item cannotbe selected or activated.

WebDataMenu Disabling Menu Items 01.png