Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the cursor in ASP.NET while loading doesn't work without a JS alert

I want to change the cursor to an hourglass in my asp.net application to let my users know that the process is running. I searched for an answer and was advised to use JavaScript as follows:

  1. Add this JavaScript:

    function hourglass() {
        document.body.style.cursor = "wait";
    }
    
  2. then in my code in the page load event:

    btnImport.Attributes.Add("onclick", "javascript: hourglass();");
    

Where btnImport is the button they click on.

However this does not work. If I add an alert to the hourglass function. it does work. Is there some way to get this to work without the alert?

like image 672
Bob Avallone Avatar asked May 12 '10 17:05

Bob Avallone


2 Answers

How about this:

btnImport.Attributes.Add("onclick", "hourglass();");
like image 124
azamsharp Avatar answered Nov 09 '22 16:11

azamsharp


Is it an Ajax-Webapp? Then you could use an UpdateProgress Control to show while the user is waiting till import finished.

like image 2
Tim Schmelter Avatar answered Nov 09 '22 15:11

Tim Schmelter