Click here to Skip to main content
15,885,365 members
Articles / Web Development / XHTML

ASP.NET - UpdatePanelProgressExtender

Rate me:
Please Sign up or sign in to vote.
4.69/5 (10 votes)
24 Aug 2009CPOL14 min read 65.6K   3.6K   66  
An ASP.NET extender control for displaying a template based progress message overlay on UpdatePanel controls while the UpdatePanel is updating. A good Web 2.0 way of letting the user know their long running request is being processed.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="UpdatePanelProgressExtender examples" %>

<%@ Register Assembly="UpdatePanelProgress" Namespace="Vereyon.Web.UI" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <link rel="stylesheet" href="StyleSheet.css" />
</head>
<body>
    <form id="form" runat="server">
        <div>
        
            <asp:ScriptManager ID="ScriptManager" runat="server">
            </asp:ScriptManager>
            
            <h1>Element blocking example</h1>
            <div class="updatePanel">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <div class="updatePanelContent">
                            <br />
                            The UpdatePanelProgressExtender bound to this UpdatePanel only blocks the content
                            of this UpdatePanel when it is updating.<br />
                            <br />
                            <asp:Button ID="updateButton1" runat="server" Text="Update panel" OnClick="updateButton1_Click" /><br />
                            <br />
                            Last update: <%=DateTime.Now.ToString() %>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="updateButton1" EventName="Click" />
                        <asp:AsyncPostBackTrigger ControlID="externalUpdateButton1" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
            <cc1:UpdatePanelProgressExtender ID="UpdatePanelProgressExtender1" runat="server" Mode="Panel" TargetControlID="UpdatePanel1" CssClass="progressMessage">
                <ProgressTemplate>
                    <img src="Images/ajax-loader.gif" alt="Loading" />
                    <br />
                    Please wait while your request is being processed...
                </ProgressTemplate>
            </cc1:UpdatePanelProgressExtender>
            <asp:Button ID="externalUpdateButton1" runat="server" Text="Update button outside update panel" OnClick="externalUpdateButton1_Click"  />
            
            <h1>Full blocking example</h1>
            <div class="updatePanel">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <div class="updatePanelContent">
                            <br />
                            The UpdatePanelProgressExtender bound to this UpdatePanel blocks the whole page
                            when the UpdatePanel is updating.<br />
                            <br />
                            <asp:Button ID="updateButton2" runat="server" Text="Update panel" OnClick="updateButton2_Click" /><br />
                            <br />
                            Last update: <%=DateTime.Now.ToString() %>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="updateButton2" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
            <cc1:UpdatePanelProgressExtender ID="UpdatePanelProgressExtender2" runat="server" Mode="Page" TargetControlID="UpdatePanel2" CssClass="progressMessage">
                <ProgressTemplate>
                    <img src="Images/ajax-loader.gif" alt="Loading" />
                    <br />
                    Please wait while your request is being processed...
                </ProgressTemplate>
            </cc1:UpdatePanelProgressExtender>
        </div>
        
        <script type="text/javascript">
//<![CDATA[
$.blockUI.defaults.css = {}; 
//]]>
        </script>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Netherlands Netherlands
Developer at AlertA contractbeheer.

Comments and Discussions