Tuesday, October 2, 2012

Strategies for implementing a 'Wait Notification' for a long running operation: AJAX

If you're looking for a way to inform the users of your ASP .NET web application that processing is actually taking place during a long running process and you happen to be using an AJAX UpdatePanel control, here is a strategy that you can use that will keep your users informed.  In order to make this work, you will need to make certain that the following three controls exist on your ASPX page (NOTE: two of these controls, the asp:ScriptManager and asp:UpdatePanel, will already be present on your page if you're already using an asp:UpdatePanel control on your web page):

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdateProgress ID="updateProgress" AssociatedUpdatePanelID="updatePanel1" runat="server" DynamicLayout="true">
    <ProgressTemplate>
        <div align="center" id="div_ProcessingMessage" runat="server"><span>Processing...</span></div>
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="updatePanel1" runat="server">'
...

After these changes are in place, you can fire up your application and the message or image contained in the <div> tag will pop up in the specified location whenever a postback is triggered on the page.  The longer the process takes, the longer this message will stay visible to the users.  Once the postback operation is complete, the message will be hidden again.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.