Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the cursor to an hourglass while server is working 1

Status
Not open for further replies.

jjk238

Programmer
Jan 16, 2003
14
0
0
US
I am trying to change the arrow cursor to an hourglass.
- The user clicks a button
- The onClick event (in C#) hits the server and takes about 8-10 seconds to query and populate the gridview. I would like the hourglass to show during this time.

All code is written in VS.NET 2005 with ASP.NET and C# using IE7. I am an extreme amateur with Java, and I don't really know where to begin. So far I have this:

<script type="text/javascript">
<!--//
function turnOn() {
document.body.style.cursor = "wait";
}

function turnOff() {
document.body.style.cursor = "default";
}
-->
</script>

I don't know how to fire this code when the button is clicked and then have it change the cursor back when the gridview is populated.

I have looked everywhere and can't figure this out. Any help is greatly appreciated....thanks!!!
 
Code:
<input type="button" [b]onClick="turnOn();"[/b] />

I'm assuming your page reloads once the grid view is populated, so you don't need to turn it off, the postback should take care of that.

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Thanks for your help, but I am still doing something wrong. The problem that I'm having is calling that function. I need it to fire off two onclick events, and I can't get the syntax working. I followed this thread and also googled it with no luck:

Here's what I have:

<asp:Button ID="btnRun" runat="server" Text="Run Application Search" Height="44px" Width="171px" OnClick="btnRun_Click(); turnOn();" />


It errors out on compiling. I've tried many variations of the onClick but can't seem to get it to work.
 
Try swapping the js calls:

Code:
<asp:Button ID="btnRun" runat="server" Text="Run Application Search" Height="44px" Width="171px" OnClick="[b]turnOn();btnRun_Click();[/b]" />

if that doesn't work, try this

Code:
<asp:Button ID="btnRun" runat="server" Text="Run Application Search" Height="44px" Width="171px" OnClick="btnRun_Click();" [b]OnClientClick="turnOn();"[/b] />

^ if that doesn't work, someone else may need to step it.

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
I still couldn't get them to run using the same onClick event, so I ended up using the second one and it worked.

OnClick="btnRun_Click" OnClientClick="turnOn()"

Thanks for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top