This is a migrated thread and some comments may be shown as answers.

Disable DropDownList

1 Answer 128 Views
FormDecorator
This is a migrated thread and some comments may be shown as answers.
Den
Top achievements
Rank 1
Den asked on 05 Jun 2012, 06:39 AM
Hello!

I use RadFormDecorator for styling. My form contains a DropDownList (asp:DropDownList). I want to disable/enable the DropDownList by javascript.
if (chb.checked) {
   jQuery("#" + ddlId).removeAttr('disabled');
} else {
   jQuery("#" + ddlId).attr('disabled', 'disabled');
}

It works good in FF and Chrome. But it does not work in IE.
How can I fix it?

Thanks 

1 Answer, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 06 Jun 2012, 11:16 AM
Hi Den,

In IE there is an issue with the disabled property of the DOM elements, when it comes to tracking it. This issue is reproduced only when the element is enabled and should become disabled. The other way around the tracking is working, i.e. if the select is disabled it can be enabled and IE will raise an event about it. This is a browser issue and there is nothing that we can do on our side to work around it.

Nevertheless there is a different approach that should work. For decorated select elements there is a FormDecorator method to update the decoration on it when the disabled property changes. Here is a sample piece of code:
Sys.Application.add_load(function()
{
    $addHandler($get("checkbox"), "click", function()
    {
        var fd = getFormDecorator();
        var select = $get("select");
        select.disabled = !$get("checkbox").checked;
        fd.updateSelect(select);
    })
              
});
              
function getFormDecorator()
{
    return $find("theFormDecorator");
}

Hope this helps.

All the best,
Niko
the Telerik team
Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
Tags
FormDecorator
Asked by
Den
Top achievements
Rank 1
Answers by
Niko
Telerik team
Share this question
or