We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to disable a menu item in menu control?

Thread ID:





125164 Jul 26,2016 09:37 PM UTC Mar 15,2017 09:53 AM UTC ASP.NET Web Forms 7
Tags: Menu
Edwin Romero
Asked On July 26, 2016 09:37 PM UTC

Hi Friends,
I have a menu this work well, but I must  enabled or disabled each item depending on your authorizations.  Authorizations are in the database, I need that you guide me as I enable or desahilitar the menu by code behind, either hide menu option or disable it

Versión 14.2460.0.26

In advance thank you very much for your help

Kasithangam C [Syncfusion]
Replied On July 27, 2016 11:11 AM UTC

Hi Edwin,   
Thanks for contacting Syncfusion support.     
We can disable the menu item by using “htmlAttribute” property. “HtmlAttribute” is one of the member in “fields” property. The value specified for the “htmlAttribute” will be included to the corresponding menu item.   
We have prepared the sample based on your requirement and you can find the sample under the following location:   

Sample: Sample 

In this sample, we have added the “e-disable-item” class value in “htmlAttribute” property. Please refer the below code to define the class value in the “htmlAttribute” in codebehind.   
sites.Add(new menufields { id = "11", parentId = 1, text = "Algeria", sprite = "flag-dz",htmlAttr=new html() { Class="e-disable-item"} });</code> 
Now during control creation, map it to the “htmlAttribute” in fields as shown below, 
<ej:Menu ID="sitemenu" DataIdField="id" DataParentIdField="parentId" DataTextField="text" DataSpriteCssField="sprite" DataHtmlAttributeField="htmlAttr" runat="server"></ej:Menu> 
To know more details about properties, methods and events of Menu Component, please refer the following API link,   


Edwin Romero
Replied On July 27, 2016 08:16 PM UTC

thanks for your quick response, I'm sure that it'll be very useful, I have a question else there is a way to change disable or enable if some item of menu is not being created at runtime, i.e. is designed by html I have that menu and want at runtime change (disable or enable) certain ítems;  example, I have menú below I want to disable "mnuUseUser" is there any way?

        <ej:Menu ID="mnuSec" Width="500px" runat="server" AnimationType="Default" DataHtmlAttributeField="htmlAttribute" DataIdField="id" DataImageAttributeField="imageAttribute" DataImageUrlField="imageUrl" DataLinkAttributeField="linkAttribute" DataParentIdField="parentId" DataSourceCachingMode="None" DataSpriteCssField="spriteCssClass" DataTextField="text" DataUrlField="url" MenuType="NormalMenu" meta:resourcekey="SyncfusionProductsResource1" Orientation="Horizontal" SubMenuDirection="None" BorderStyle="Outset">
                <ej:MenuItem ID="mnuPar" Text="Parámetros">
                        <ej:MenuItem ID="mnuParMod" Text="Módulos">
                        <ej:MenuItem ID="mnuParPag" Text="Páginas">

                <ej:MenuItem Id="mnuUser" Text="Usuarios">

                        <ej:MenuItem ID="mnuUseRol" Text="Roles">
                        <ej:MenuItem ID="mnuUseUser" Text="Registro" Url="~/SegRegistro.aspx">
                        <ej:MenuItem ID="mnuUsePerfil" Text="Perfil de usuario" Url="">




Well In advance thank you very much for your help

Kasithangam C [Syncfusion]
Replied On July 28, 2016 01:21 PM UTC

Hi Edwin, 

Thanks for your update. 

Currently we are not able to disable/enable submenu item while created the menu by html. We have considered this as a bug. Can you please check the incident (161258) for further updates? 


Edwin Romero
Replied On July 28, 2016 07:31 PM UTC

Ok thanks a lot Kasithangam 
You've been very helpful. I will periodically review the incident that you refer me


Kasithangam C [Syncfusion]
Replied On July 29, 2016 04:36 AM UTC

Hi Edwin, 
Thanks for your update. Please get back to us if you have further query. We will be happy to help you out. 


Mike Potratz
Replied On March 14, 2017 01:50 PM UTC

Has this "bug" been fixed?  If so, are there any examples of using it?

Prince Oliver [Syncfusion]
Replied On March 15, 2017 09:53 AM UTC

Hi Mike,   
Thank you for contacting Syncfusion support.   
We have fixed it and its available since 2016, volume 2 SP-2 release.   
To disable the submenu item, you can access the submenu item by using id and add the HtmlAttribute property in codebehind. Kindly refer to the following code example.   
  protected void butt_Click(object sender, EventArgs e)   
      adsearch.HtmlAttributes = "class=e-disable-item";   
Also, you can use the HtmlAttribute property for sub menu item in menu control. Kindly refer to the following code example.   
<ej:MenuItem Id="Resume" Text="Resume writing" HtmlAttributes="class=e-disable-item" Url="~/Contact.aspx"></ej:MenuItem>   
If you are using URL attribute in the submenu item, then we need to avoid the URL navigation for a disabled item. This can be done by using jQuery's preventDefault method. Kindly have a look at the following code example.    
<ej:MenuItem Id="Resume" Text="Resume writing" Url="~/Contact.aspx"></ej:MenuItem>    
        $("#Resume").click(function (event) {    
Refer to the following link for the sample:    


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon