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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to change the enabled / disabled status of a dropdownlist through a button?

Thread ID:





143482 Mar 21,2019 06:42 PM UTC Mar 22,2019 05:54 AM UTC ASP.NET MVC - EJ 2 1
Tags: DropDownList
Juan Cruz
Asked On March 21, 2019 06:42 PM UTC

Hello, I am working with a dropdownlist with the property enabled in false and I wanted to know if it can be changed to true through a button
Here is my code:

                                                    .DataSource(dataManager => dataManager.Url(Url.Action("Genre", "Ext", null, Request.Url.Scheme))
                                                    .Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings
                                                        Text = "Name",
                                                        Value = "GenreId"
<button class="btn btn-success" id="btnChange">Change</button>
<script type="text/javascript">
          var x = document.getElementById("GenreId").ej2_instances[0];
          x.element.disabled = false;
        x.element.readOnly = false;
        x.properties.enabled = true;
I do not know if this is the right way to do it. I hope you can help me.
Thanks in advance

Prince Oliver [Syncfusion]
Replied On March 22, 2019 05:54 AM UTC

Hello Juan, 

Thank you for contacting Syncfusion support. 

Yes, it is possible to change the enabled / disabled status of a DropDownList through a button. All you need to do is use the enabled property in the control and set it as true to enable and false to disable it. You can call the dataBind method to reflect the changes immediately in the control. Please refer the below code. 

$("#btnChange").click(function () { 
  var x = document.getElementById("GenreId").ej2_instances[0]; 
  if (x.enabled) { 
    x.enabled = false; // To disable 
    x.dataBind(); //To affect the changes immediately 
  } else { 
    x.enabled = true; // To enable 
    x.dataBind(); //To affect the changes immediately 

Let us know if you have any further queries. 



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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon