【问题标题】:How do I show progress to the user when fetching data via a series of webservice calls in asp.net?通过 asp.net 中的一系列 Web 服务调用获取数据时,如何向用户显示进度?
【发布时间】:2012-06-16 04:09:39
【问题描述】:

我有一个 asp.net 控件 (.net 3.5),它对 web 服务进行一系列调用,以从数据库中获取数据,然后将其放入 gridviews。由于每个数据库查询都需要几秒钟的时间,我会在一系列调用中完成,而不是一次性完成,否则会超时。

在返回所有数据之前,页面似乎不会呈现。我如何在每次调用时向用户显示进度,以让他们相信某些事情正在实际发生?

网格包含财务数据。用户选择月份和年份,然后按下一个按钮来启动这个 web 服务调用序列。所以这通常发生在回发中(尽管页面最初呈现的是当前月份和年份的数据,如果有的话)。

我遇到过UpdatePanels。这会使每个表格在数据填充时呈现吗?

编辑:这是我到目前为止使用 Sunny 的建议所尝试的方法

.ascx 文件

<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server">
    <ProgressTemplate>
      UpdatePanel1 updating...
    </ProgressTemplate>
    </asp:UpdateProgress>
<asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="UpdatePanel2" runat="server">
    <ProgressTemplate>
      UpdatePanel2 updating...
    </ProgressTemplate>
    </asp:UpdateProgress>

<asp:Label runat="server" ID="lblOB"></asp:Label><asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <contenttemplate>
<h3><asp:Label runat="server" ID="lblT1"></asp:Label></h3>
<asp:GridView runat="server" id="gridT1">
</asp:GridView>

    </contenttemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <contenttemplate>
<h3><asp:Label runat="server" ID="lblT2"></asp:Label></h3>
<asp:GridView runat="server" id="gridT2">
<Columns>
    </Columns>
    </asp:GridView>
    </contenttemplate>
</asp:UpdatePanel>

.ascx.vb 文件:

 (Pseudo code)
 Call webservice for table 1
 gridT1.datasource = table 1 data from webserivce
 gridT1.DataBind()
 lblT1.text = heading

 Call webservice for table 2
 gridT2.datasource = tabld 2 data from webserivce
 gridT2.DataBind()
 lblT12text = heading

【问题讨论】:

    标签: asp.net web-services .net-3.5


    【解决方案1】:

    这里可以使用Ajax加载器或者UpdateProgress Ajax控件。

    【讨论】:

    • 我已经将几个 UpdatePanel 和相应的 UpdateProgress 部分放在一起,但是在页面运行时我看不到 UpdateProgress 部分的内容。
    • 我还制作了一个应用程序,其中我有很多更新面板,但 UpdateProgress 在那里工作得很好,你能提供一些 aspx 代码吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-02
    • 2019-08-09
    相关资源
    最近更新 更多