How do I change a cursor to 'wait' state during listbox load in C#

I have several listboxes I populate with stored procedures in my code but have not had any luck implementing the cursor to "wait' state while the stored procedure is working.  
The app (coded in C# for asp page)  utilizes nothing but stored procs for all data.

I have tried using:
btnGO.Attributes.Add("onclick", "document.body.style.cursor = 'wait';"); //placed in the page_ load() event and used this line of code below to change it back in my button_click event().

dgResults.Attributes.Add("OnDataBinding", "document.body.style.cursor = default;");

It does work but I cannot turn it off or turn it on again and it only goes back to normal default arrow when moving mouse over a list box.  The only other way to get it back to default is to reload the page.

I would like to use this cursor change every time the buttoon_Clcik event fires as this will show the user that the app is doing something.

Thanks in advance
Shay10Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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

and call this script
0
Mahmoud_Al_HattabCommented:
well, I am not sure about web, but in desktop applications I use this
Cursor.Current = Cursors.WaitCursor;
// do the work here then:
Cursor.Current = Cursors.Arrow;
0
Shay10Author Commented:
It's asp web page - coding in C#.  That's the environment I am working in - I am restricted from using Java as well.
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

SriVaddadiCommented:
You mean you can't use java script?

You can run the java script from the C# code behind code.

Check this out

http://msdn.microsoft.com/en-us/library/btf44dc9.aspx
0
Mahmoud_Al_HattabCommented:
ok check this please: from: http://www.thescarms.com/dotnet/AspWaitCursor.aspx
Add this JavaScript between the  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  tag:

   
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();">
0
Mahmoud_Al_HattabCommented:
check this as well please, from: http://forums.techarena.in/software-development/1109618.htm

onload event fires when the page has completely rendered

you will have to do the following

set the cursor to wait on any postback events u do like button click

Code:

and on body load u will have to set it to default

Code:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.