10分求解asp.net ajax updatepanel局部页面刷新问题。

来源:百度知道 编辑:UC知道 时间:2024/07/02 09:31:34
.aspx文件中的部分代码如下:
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="205px"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server" Height="109px" Width="209px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBa

几个问题:
第一,感觉你没有必要用两个UpdatePanel
第二,Triggers只对外面的控件有效,因为你外面的控件在另一个UpdatePane里面,所以它找不到UpdatePane里面的控件
第三,Triggers只有当UpdatePane的UpdateMode属性设置为Conditional时才有效,你改成以下试试

<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="205px"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:ListBox ID="ListBox1" runat="server" Height="109px" Width="209px"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>

AutoPostBack="True"
自动回发给服务器 每次触发selectedIndexChanged事件 就会把相关数据传给服务 服务器处理完selectedIndexChanged事件后, 重新生