Wait cursor for ASP.Net Ajax actions
Suppose you have a page where you have a bunch of actions that invoke an Ajax callback. You can use the UpdateProgress control to indicate that the request is being invoked, for example to display some “please wait†text.
But that’s not it happens in the world of Winforms (or more broadly, desktop apps). You just get a wait cursor most of the time. The same happens when you do a normal postback (and some addition feedback too, granted).
It’s not very hard to add wait cursor support to your pages. Add the following script block right after the <asp:ScriptManager> tag:
-
<script type="text/javascript">
-
-
var prm = Sys.WebForms.PageRequestManager.getInstance();
-
prm.add_initializeRequest(InitializeRequest);
-
prm.add_endRequest(EndRequest);
-
-
function InitializeRequest(sender, args) {
-
document.body.style.cursor = ‘wait’;
-
}
-
-
function EndRequest(sender, args) {
-
document.body.style.cursor = ‘default’;
-
}
-
-
</script>
This works separately from any UpdateProgress panels you have on the page. It also works for all UpdatePanel instances: for every Ajax request the cursor turns into an hourglass while the request is doing it’s work.
About this entry
You’re currently reading “Wait cursor for ASP.Net Ajax actions,” an entry on Inferis’ Code Dump
- Published:
- 18.01.08 / 3pm
- Category:
- ASP.Net, Ajax, Javascript, UI
5 Comments
Jump to comment form | comments rss [?] | trackback uri [?]