为什么设置 AssociatedUpdatePanelId 后更新进度不会触发?
当我分配 AssociatedUpdatePanelId 时,当我选择状态时不会显示进度,但当我将其留空时,它会显示进度。
这是 aspx 标记:
<div>
<asp:ListBox ID="lstStates" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="lstStates_SelectedIndexChanged" SelectionMode="Multiple">
</asp:ListBox>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlCounty" runat="server">
<asp:ListBox ID="lstCounties" runat="server" SelectionMode="Multiple">
</asp:ListBox>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lstStates" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img src="../images/loader2.gif" />
Loading Counties...
</ProgressTemplate>
</asp:UpdateProgress>
</div>
When I assign the AssociatedUpdatePanelId, the progress does not display when I select a state, but when I leave it blank, it displays the progress.
Here is the aspx markup:
<div>
<asp:ListBox ID="lstStates" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="lstStates_SelectedIndexChanged" SelectionMode="Multiple">
</asp:ListBox>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlCounty" runat="server">
<asp:ListBox ID="lstCounties" runat="server" SelectionMode="Multiple">
</asp:ListBox>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lstStates" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img src="../images/loader2.gif" />
Loading Counties...
</ProgressTemplate>
</asp:UpdateProgress>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 本文,UpdatePanel 的外部触发器不会触发关联的 UpdateProgress,由于启用 UpdateProgress 控件的实现会在控件层次结构中搜索调用控件; 外部触发器不会出现在控制层次结构中。
然而,这篇文章确实建议注入一些 JavaScript 来弥补这个错误; 我已经对其进行了修改(希望)满足您的需求:
According to this article, external triggers for an UpdatePanel do not fire an associated UpdateProgress, since the implementation of enabling the UpdateProgress control searches the control hierarchy for the calling control; an external trigger will not be present in the control hierarchy.
The article does, however, suggest injecting some JavaScript to make up for this error; I have modified it to (hopefully) fit your needs:
不要忘记
使用
.NET 为控制器创建自己的名称(实际上附加“MainContent”或其他名称)。
Don't forget instead of
to use
as .NET makes up its own name for the controller (actually appends "MainContent" or whatever to it).