Question

How can I show loading image for the user while executing long running process in an ASP.Net Ajax application? Is there a way other than using Page Methods? Any ideas?

Was it helpful?

Solution

on client side you can hook up Sys.WebForms.PageRequestManager BeginRequest:

<script type="text/javascript" language="javascript">
                Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                function BeginRequestHandler(sender, args)
                {
                     var elem = args.get_postBackElement();
                     ActivateAlertDiv('visible', 'AlertDiv', elem.value + ' processing...');
                }
                function EndRequestHandler(sender, args)
                {
                     ActivateAlertDiv('hidden', 'AlertDiv', '');
                }
                function ActivateAlertDiv(visstring, elem, msg)
                {
                     var adiv = $get(elem);
                     adiv.style.visibility = visstring;
                     adiv.innerHTML = msg;                     
                }
            </script>

more info: http://msdn.microsoft.com/en-us/library/bb397432.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top