CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Display Progress or Loading message without using UpdateProgress Control in ASP.Net AJAX
Submitted By Bala Murugan
On 2/21/2009 9:52:53 AM
Tags: asp.net ajax,CodeDigest,JAvaScript  

Display Progress or Loading message without using UpdateProgress Control in ASP.Net AJAX

 

As we all know, UpdateProgress control in ASP.Net AJAX can be used to let the users know that the server side process is still progressing with a loading message or through a graphic. The same requirement can be achieved by the below JavaScript code snippet without using UpdateProgress control.

 

We can do this through the client side events of PageRequestManager object. In the below code, we are enabling the DIV that has a loading image in OnBeginRequest event and disabling the same in endRequest event. OnBeginRequest event is called before every Async request is sent to the server and endRequest event is called once the request processing ends on the server and control returns to the browser.

 

 

<script language="JavaScript">

     var Page;

     var postBackElement;

     function pageLoad()

     {

      Page = Sys.WebForms.PageRequestManager.getInstance();

      Page.add_beginRequest(OnBeginRequest);

      Page.add_endRequest(endRequest);

     }

    function OnBeginRequest(sender, args)

    {       

     $get("IMGDIV").style.display="";

    }

     function endRequest(sender, args)

    {

     $get("IMGDIV").style.display="none";

    }

 

  </script>

 

<body>

    <form id="form1" runat="server">

<DIV id="IMGDIV" style="display:none;position:absolute;left: 35%;top: 25%;vertical-align:middle;border-style:inset;border-color:black;background-color:White;z-index:40;">

      <img src=icon_inprogress.gif />                   

</DIV>

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..