Wednesday, March 16, 2011

How to show progress in ASP.NET WebForms by UpdatePanel

         <script type="text/javascript">
             var prm = Sys.WebForms.PageRequestManager.getInstance();
             prm.add_initializeRequest(prm_InitializeRequest);
             prm.add_endRequest(prm_EndRequest);
            
             function prm_InitializeRequest(sender, args) {
                 var panelProg = $get('divImage');                
                 panelProg.style.display = '';
             }

             function prm_EndRequest(sender, args) {
                 var panelProg = $get('divImage');                
                 panelProg.style.display = 'none';
             }
         </script>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div id="divImage" style="display:none">
                     <asp:Image ID="img1" runat="server" ImageUrl="~/images/progress.gif" />
                     Processing...
                </div>                
                <br />
                <asp:Button ID="btnInvoke" runat="server" Text="Click"
                    onclick="btnInvoke_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>


No comments:

Post a Comment