×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Make the mouse pointer an hourglass
8

Make the mouse pointer an hourglass

Make the mouse pointer an hourglass

(OP)
Anyone ever done this on a webform? When a query is being performed, it would be nice to make the mouse pointer an hourglass...

Cheers

Chris

RE: Make the mouse pointer an hourglass

Hey Chris,

It is possible, but it requires some know-how of CSS to do it (which i unfortunatley have little know-how about, newbie in that department).

You might want to try and post something in the HTML and CSS forum and see if anyone there can point you in the right direction.
:)

Jack

RE: Make the mouse pointer an hourglass

(OP)
Thanks, Jack, I'll try that

Chris says: "It's time for a beer."

RE: Make the mouse pointer an hourglass

Hey bud,

You can do this in html(css) with 'style="cursor:wait"' so I'm not exactly sure what you would want to do but you could apply it to an html element with javascript like: 'this.style.cursor="wait"'.

I'm not too sure how you would go about mixing this with your ASP but hope this gives you something to work with.

P.S I think this is only an I.E thing too.


01101000011000010110010001110011

RE: Make the mouse pointer an hourglass

in the head of your aspx file, simple put this in and change btnName to the name of your button

<SCRIPT LANGUAGE="vbscript">
<!--
  Sub btnName_onclick
     document.body.style.cursor = "wait"
  End Sub
-->
</SCRIPT>

the only problem is possibly with mixing vbscript and javascript code on the client.

there's probably a better way to do this, like register a script for the client click on the button to call a javascript function with the same thing, but vbscript event handlers don't need an onclick="" attribute of the triggering element to fire....the script automatically pools the page and waits for the button to be clicked.

mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu

RE: Make the mouse pointer an hourglass

another idea...

document.getElementById("btnName").setAttribute("value","Please Wait...")

this could also be in there too...it'll change the button's text to "please wait..."

anyone thinking about a custom submit button control??

mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu

RE: Make the mouse pointer an hourglass

(OP)
Thanks, Mike,
  I think I will have to do the label thing ("Please wait while your query is processed") or something. It would be nice to do the hourglass thing, but I am facing time constraints now... Thanks a bunch though!

If anyone does know how to make the mouse pointer an hourglass when the user presses a server control asp button please post - I could easily add it later to my project...
TIA

Chris says: "It's time for a beer."

RE: Make the mouse pointer an hourglass

here you go....try this as the codebehind for a user control

----------------------------------------------

using System;
using System.Web;
using System.Web.UI;
using System.Text;

namespace truck_sales_and_service
{
    /// <summary>
    /// Summary description for WaitingButton.
    /// </summary>
    public abstract class WaitButton : System.Web.UI.UserControl
    {
        protected string _Text;
        protected string _ClassName;

        public string Text
        {
            get { return _Text; }
            set { _Text = value; }
        }

        public string ClassName
        {
            get { return _ClassName; }
            set { _ClassName = value; }
        }

        protected override void OnPreRender (EventArgs e)
        {
            Page.RegisterClientScriptBlock (
                "__doAlert",
                "<script language=\"javascript\">\n" +
                "<!--\n"+
                "function __doWait (btnWaiter)\n" +
                "{\n" +
                " btnWaiter.setAttribute(\"value\",\"Please Wait...\");\n" +
                " document.body.style.cursor=\"wait\";\n" +
                "}\n" +
                "-->\n"+
                "</script>"
                );
        }

        protected override void Render (HtmlTextWriter writer)
        {
            StringBuilder builder = new StringBuilder ();

            builder.Append ("<input type=\"submit\" value=\"");
            builder.Append (_Text);
            builder.Append ("\" onclick=\"javascript:__doWait (this);\"");
            if (_ClassName != null)
            {
                builder.Append(" class=\"");
                builder.Append(_ClassName);
                builder.Append("\"");
            }
            builder.Append ("/>");

            writer.Write (builder.ToString ());
        }
    }
}


--------------------------------------------

then

<%@ Register TagPrefix="mdg12" TagName="WaitingButton" Src="WaitingButton.ascx" %>
<form runat="server">
<msg12:WaitingButton text="hello" runat="server" />
</form>

mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu

RE: Make the mouse pointer an hourglass

(OP)
Thanks Mike, I have never made a user control before, so this will take a bit of time. I'll post back when I figure it all out to let you know if it worked or not

Chris says: "It's time for a beer."

RE: Make the mouse pointer an hourglass

7
I have a button named cmdReport.  In my aspx.vb file's  Page_Load sub I put this :
cmdReport.Attributes("onclick") = "javascript: hourglass();"

Then in the <HEAD> of my .aspx file I put this:
<script language="javascript">
function hourglass()
{
    document.body.style.cursor = "wait";
}
</script>

Works great for me and it's simple.

Shanti

RE: Make the mouse pointer an hourglass

and yes, it's a server control button.  I couldn't figure out a way to add the onclick attribute without adding that code to the Page_Load sub.  I kept getting errors trying to manually add an onclick to the html for the asp:button.  But with the way I showed above, it worked fine.

RE: Make the mouse pointer an hourglass

kick @$$ Shanti (millerk), thanks for the post!
:)

Jack

RE: Make the mouse pointer an hourglass

(OP)
Shanti:
This works so well, it is going in my bag of tricks.
Thanks a million!

Life is like a box of chocolates, sweet

RE: Make the mouse pointer an hourglass

millerk, you should FAQ this.

would make a very nice addition.

RE: Make the mouse pointer an hourglass

millerk, the hourglass part works great after a button click etc, but now the cursor shows up as a hourglass (even after post back ) when I hover it over the other controls on the page ( ex Labels)... though it shows up as a normal pointer hovering over the the button .

..what might be causeing this?

RE: Make the mouse pointer an hourglass

Wow.  Two year later, I don't even remember what app I used this for.  I really don't do much web programming so I can't really help you.

Hopefully someone will have an answer for you.

RE: Make the mouse pointer an hourglass

It looks as if after setting the cursor to "wait", there's nothing to trigger it to go back to "default", though I am not sure as I've never tinkered with cursors like this.

Try calling this code when you see fit:


function backtonormal()
{
    document.body.style.cursor = "default";
}

RE: Make the mouse pointer an hourglass

Yeah, I think in the app where I used that, clicking the button did some processing, then went to another page.  That may be the reason I didn't have that issue.

RE: Make the mouse pointer an hourglass

BoulderBum, how do i "call" the java script code??
I use this to call it for the hourglass thing
mybutton.Attributes.Add("onclick", "javascript:hourglass();");

but this is event based ( onclick), how do I call the backtonormal () script  assuming It shoudl be called on page postback?

(using C#)

thx

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close