• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3557
  • Last Modified:

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
0
Shay10
Asked:
Shay10
  • 3
  • 2
1 Solution
 
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now