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?
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
精彩评论