【问题标题】:Updatepanel's Updateprogress not displaying on loadUpdatepanel 的更新进度未在加载时显示
【发布时间】:2014-03-20 20:11:05
【问题描述】:

我将大量数据填充到Asp.net 转发器控件中。我需要实现“加载”消息,直到数据加载。我正在尝试Updatepanel/Updateprogress 组合,但到目前为止,UpdateProgress 文本没有显示。

这是我的代码。 Repeater 控件构建并加载jquery datatable

<div style="clear:both;padding-top:15px;">
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate >
   Please wait ...
</ProgressTemplate>
 </asp:UpdateProgress>     

 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate>                                          
  <asp:Repeater runat="server" ID="rptGrid">
    <HeaderTemplate>
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="Grid">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Location</th>
                </tr>
            </thead>
    </HeaderTemplate>
    <ItemTemplate>
        <tr class='nondraft'>
            <td><%# Eval("EmployeeName") %></td>
            <td><%# Eval("Location")%></td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </tbody>
        </table>
    </FooterTemplate>
    </ContentTemplate>                                 
 </asp:UpdatePanel>
 </div>

知道我做错了什么吗? 谢谢

【问题讨论】:

  • 你在页面中添加了脚本管理器吗?

标签: jquery asp.net ajax updatepanel


【解决方案1】:

这是因为您没有将异步回发添加回您的代码。您可以在

之后添加该代码
</ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="IdName" EventName="YourEventName" />
    </Triggers>
</asp:UpdatePanel> 

您需要编写控件ID,即您需要在其上显示更新进度的控件,例如按钮。

【讨论】:

  • 这对我不起作用。也没有将我的隐藏按钮放在 UpdatePanel 中(以便它自动成为子触发器)。该按钮被单击确定,UpdatePanel 按预期刷新,但 UpdateProgress 不起作用 - 原始问题:(
【解决方案2】:

如果我理解正确,您希望在页面第一次加载时显示加载消息。

在这种情况下,UpdateProgress 将没有任何帮助。 UpdateProgress 只会在更新面板中出现异步回发时显示。

一种方法是使用 ajax 加载转发器数据。因此,第一次加载时页面实际上是空的,并带有加载消息。然后你进行ajax调用来获取数据

我隐约记得使用 iframe 之类的其他 hack,或者可能是从 javascript 执行强制 __doPostBack 或从 javascript 执行重定向。

【讨论】:

    【解决方案3】:

    您应该改用模态弹出扩展器来显示“请稍候....”消息,直到您的转发器正在加载。在您的情况下,由于没有发生实际的回发,因此无法触发更新进度。您可以访问http://www.codeproject.com/Articles/34996/ASP-NET-AJAX-Control-Toolkit-ModalPopupExtender-Co 获取客户端代码以打开和关闭弹出窗口。

    但是,如果您仍然想使用更新进度,请执行以下操作:

    1) 在更新面板中添加一个按钮并将其隐藏。

    <asp:Button ID="YourButton" runat="server" Visible="false" />
    

    2) 添加以下javascript代码:

    function Update_UpdatePaanel() 
    {
        document.getElementById('<%= YourButton.ClientID %>').click();
    }
    

    希望这会有所帮助。

    【讨论】:

    • 这对我不起作用。行为与我使用的行为相同: document.getElementById("YourButton").click();即点击了不可见的按钮,但我的进度文本仍未显示:(
    猜你喜欢
    • 2012-04-24
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多