更新UpdatePanel外部的控件

Rya*_*ndy 13 c# asp.net ajax updatepanel asp.net-ajax

所以我有UserControl一些级联DropDownList的东西.从列表1中选择启用列表2,列表2依次启用列表3.在所有三个列表中进行选择后,您可以转到下一页.

DropDownLists为所有内部的UpdatePanel.但是"下一页"按钮在...之外UpdatePanel.应该禁用该按钮,直到所有三个列表都有选择,然后再次启用它.但由于按钮位于按钮之外UpdatePanel,因此在进行选择时不会更新.(编辑:"下一页"按钮位于同时包含该页面的页面上UserControl.)

我知道解决这个问题的一种方法:

var scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterPostBackControl(dropDownList1);
scriptManager.RegisterPostBackControl(dropDownList2);
scriptManager.RegisterPostBackControl(dropDownList3);
Run Code Online (Sandbox Code Playgroud)

这可以确保在更改任何下拉列表时进行回发,以便按钮可以更新.但是,如果我这样做,我可以通过UpdatePanel首先摆脱它来简化.

还有另外一种方法,通过一些聪明的JavaScript或其他东西,我可以在UpdatePanel不必放弃Ajax 的情况下更新控件吗?

Jim*_*kus 12

在下一个按钮周围放置一个UpdatePanel,并为每个下拉菜单创建一个触发器,以便它触发异步回发.例如:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="dropDownList1" />
    <asp:AsyncPostBackTrigger ControlID="dropDownList2" />
    <asp:AsyncPostBackTrigger ControlID="dropDownList3" />
</Triggers>
Run Code Online (Sandbox Code Playgroud)


thm*_*msn 7

您是否可以在"下一页"周围添加更新面板,然后在下拉列表更新面板中添加触发器以触发下一页更新面板?

只是抛出想法,而没有真正尝试过:)