Change the default cursor to a Wait cursor in ASP.NET
Hi,
In my Asp.net application when a new page is loading i want that the default cursor should be change to wait cursor. I can do the same thing for the windows application but for web project i don't have any idea.
In Windows-Based Applications I'm using:
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
How can I use something similar in ASP?
Thanks.
Re: Change the default cursor to a Wait cursor in ASP.NET
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:
Code:
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:
Code:
<body onbeforeunload="setHourglass();" onunload="setHourglass();">
Re: Change the default cursor to a Wait cursor in ASP.NET
Hi
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:
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick = "document.all[1].style.cursor = wait"/>
and on body load u will have to set it to default
Code:
<body onload="document.all[1].style.cursor = 'default'" >