简体   繁体   English

禁用Ajax级联下拉菜单

[英]Disabling Ajax Cascading Dropdown

I have 4 Ajax Toolkit cascading dropdowns on my page. 我的页面上有4个Ajax Toolkit级联下拉菜单。

Under certain conditions on load I set the selected values on the first 2. I now want to disable the first 2 dropdowns in these conditions so they still function but the user cant change the selected value. 在某些负载条件下,我将选择的值设置为第一个2。现在,我想在这些条件下禁用前两个下拉菜单,以便它们仍然起作用,但用户无法更改选择的值。 I've tried setting enabled to false on the dropdown box but it seems the Cascading extender overrides this and sets it back to true. 我已经尝试在下拉框中将设置设置为false,但是级联扩展器似乎会覆盖此设置并将其设置回true。 I've also tried setting enabled to false on the extender but this causes the dropdown and child dropdowns not to be populated. 我还尝试在扩展程序上将设置启用为false,但这会导致不填充下拉菜单和子下拉菜单。

Before I start attempting a javascript solution is there another way of doing this? 在我开始尝试JavaScript解决方案之前,还有另一种方法可以做到这一点吗?

Thanks 谢谢

I achieved this by adding a custom attribute server side to the controls stating if I wanted them disabled, I called this MappedControl, I then used the following Javascript to do the disabling 我通过在控件中添加自定义属性服务器端来实现此功能,以声明是否要禁用它们,我将其称为MappedControl,然后使用以下Javascript进行禁用

function Level1Populated() {
    if ($("*[id$='ddl_OrganisationalLevel4Id']").attr("MappedControl")) {
        $("*[id$='ddl_OrganisationalLevel4Id']").disabled = true;
    }
}
function pageLoad(sender, args) {  
    $find("ccd_Level1BID").add_populated(Level1Populated);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM