AsyncPostBackTrigger 不适用于同时更新调用

发布于 2024-08-02 10:06:53 字数 1154 浏览 2 评论 0 原文

我有一个包含一些 UpdatePanel 的页面,每个 UpdatePanel 都有自己的更新按钮。由于更新例程可能需要一些时间,因此我认为将它们设为异步将有助于逐步加载页面。

但是这样做,当我以编程方式触发每个面板的更新例程时,我只更新了最后一个 UpdatePanel。

下面是一个代码示例,其中包含两个 UpdatePanel。要求必须在客户端 pageLoad 函数上触发更新例程。

这是一个错误还是我在代码中遗漏了某些内容?

谢谢=)

<asp:UpdatePanel ID="Panel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:TextBox ID="Text1" runat="server" />
    <asp:Button ID="Button1" runat="server" />
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

<asp:UpdatePanel ID="Panel2" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:TextBox ID="Text2" runat="server" />
    <asp:Button ID="Button2" runat="server" />
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

和客户端代码:

function pageLoad()
{
  $('#Button1').click();
  $('#Button2').click();
}

I have a page with some UpdatePanels, each one with its own button to update it. Since the update routines can take some time, I thought making them Asynchronous would help loading the page step by step.

But doing so, when I fire programatically the update routine of each panel, I get only the last UpdatePanel updated.

Here is an example of the code, with two UpdatePanels. There is the requirement that the update routine have to be fired on clientside pageLoad function.

Is it a bug or am I missing something in the code?

Thanks =)

<asp:UpdatePanel ID="Panel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:TextBox ID="Text1" runat="server" />
    <asp:Button ID="Button1" runat="server" />
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

<asp:UpdatePanel ID="Panel2" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:TextBox ID="Text2" runat="server" />
    <asp:Button ID="Button2" runat="server" />
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

And the client-side code:

function pageLoad()
{
  $('#Button1').click();
  $('#Button2').click();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

み格子的夏天 2024-08-09 10:06:53

原因如下:

默认情况下,当一个页面创建多个
同时异步回发
时间,最近进行的回发
优先。

http://www.asp.net/ajax/documentation/live/ Tutorials/ExclusiveAsyncPostback.aspx

这是一个解决方案:
处理多个异步回发

Here is why:

By default, when a page makes multiple
asynchronous postbacks at the same
time, the postback made most recently
takes precedence.

http://www.asp.net/ajax/documentation/live/tutorials/ExclusiveAsyncPostback.aspx

Here is a solution:
Handling Multiple Asynchronous Postbacks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文