如何重置ASP.Net AJAX级联下拉控件(客户端)

时间:2021-10-17 15:30:36

The cascading dropdown control works great except that I am unable to figure out a way to reset the dropdown client-side (in Javascript)

级联下拉控件工作得很好,除了我无法找到重置下拉客户端的方法(在Javascript中)

My set up is something like this

我的设置是这样的

DD1
DD2
DD3
DD4

each DD is dependent on the previous DD and uses webservice to load them.

每个DD都依赖于以前的DD并使用webservice加载它们。

On change of DD3 I need to reset DD4 but the previous selection stays.

在更改DD3时,我需要重置DD4,但之前的选择仍然存在。

Can this be done? I tried clearing the value in the supporting hidden input control (cddTest_ClientState) in vain

可以这样做吗?我尝试清除支持隐藏输入控件(cddTest_ClientState)中的值是徒劳的

TIA

1 个解决方案

#1


2  

Here is the solution

这是解决方案

<asp:DropDownList ID="dd1" runat="server" onChange="ondd1ChangeHandler(this)>
</asp:DropDownList>
<asp:DropDownList ID="dd2" runat="server">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cdd2" runat="server" Category="Cat1"
    ParentControlID="dd1" PromptText="(Select Option)" ServiceMethod="GetOptions"
    ServicePath="Services/GetOptions.asmx" TargetControlID="dd2">
</cc1:CascadingDropDown>

<script type='text/javascript>
    function ondd1ChangeHandler(dd){
        var dd2=$get('dd2');
        dd2.selectedIndex=0;
        var cdd=$find('cdd2');
        if(cdd!=null){
            cdd.set_SelectedValue('','');
            cdd._onParentChange(null,false);
        }
    }
</script>

Hope this helps

希望这可以帮助

#1


2  

Here is the solution

这是解决方案

<asp:DropDownList ID="dd1" runat="server" onChange="ondd1ChangeHandler(this)>
</asp:DropDownList>
<asp:DropDownList ID="dd2" runat="server">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cdd2" runat="server" Category="Cat1"
    ParentControlID="dd1" PromptText="(Select Option)" ServiceMethod="GetOptions"
    ServicePath="Services/GetOptions.asmx" TargetControlID="dd2">
</cc1:CascadingDropDown>

<script type='text/javascript>
    function ondd1ChangeHandler(dd){
        var dd2=$get('dd2');
        dd2.selectedIndex=0;
        var cdd=$find('cdd2');
        if(cdd!=null){
            cdd.set_SelectedValue('','');
            cdd._onParentChange(null,false);
        }
    }
</script>

Hope this helps

希望这可以帮助