Search Amazon:

How do I change the cursor to a Wait cursor in ASP.NET?

Often when a user clicks something on your ASP.NET web page the server side code goes off and executes a long running process. In a Winforms application you could change the cursor to a wait or hourglass cursor to inform the user that the application is busy.

With ASP.NET pages this is a bit more of a problem to do. You need to employ a little JavaScript.

Add this JavaScript between the <HEAD> tags on your ASP.NET web page:

   function setHourglass()
  {
    document.body.style.cursor = 'wait';
  }

Now you have to tell the web form to run the JavaScript funciton when a post back happens.

Add this to your <BODY> tag:

   <body onbeforeunload="setHourglass();" onunload="setHourglass();">

The onbeforeunload and onunload events in Internet Explorer fire prior to the page unloading during the start of the post back operation. The cursor will change to an hourglass then when the page gets posted back and re-renders, the cursor is set back to the default.

Or, you can add the following line to the FORM tag instead.

   <form runat="server" onsubmit="return setHourglass();">

Sign In
  User Id 
  Password 


Submit Your Own Code and Articles




About TheScarms
About TheScarms

Ask me your programming questions

I read every email and answer all I can.

User Feedback: Be the first to add a comment! Items to Show:     

     
You must log in to post feedback.
Comment:    
 

If you use this code, please mention "www.TheScarms.com"

Email this page


TheScarms AppSentinel lets you securely copy protect and create evaluation versions of your software

TheScarms(tm) AppSentinel lets you quickly and easily create evaluation versions of your software and stop unauthorized copying and unregistered use of your programs!

Get your free
trial copy today!


      The World's Number 1 Web Host

© Copyright 2008 TheScarms