Wednesday, January 5, 2011

Change Cursor to an Hourglass for Web Applications

To accomplish this on the web you'll need to call a javascript or use CSS. This is a javascript example. In your aspx page add this code in the header or above your content:

wrap it in a script tag

function hourglass()
{
document.body.style.cursor = "wait";
}
 
In your aspx.cs code behind add this C# code in your Page Load (obviously change the button name to match yours)
 
btnSubmit.Attributes.Add("onclick", "javascript: hourglass();");

In my example the page redirects to another page, so the cursor set itself back automatically, but you may need to set it back to "default" yourself.

No comments:

Post a Comment