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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hanging cursors by attaching a javascript fct to a vb button. Doesn't

Status
Not open for further replies.

phfle1

Programmer
May 22, 2007
16
CA
Hi,

I'm building an application with VS2005 using Visual Basic .NET and asp.net. I'm testing the code with IE.

I need the cursor to change when I click on a button until some process is completed(until postback)
It seems pretty straightfoward, but I probably have something wrong. Here is what I do:

in vb.net
Me.btnRecherche.Attributes.Add("onclick", "document.body.style.cursor = 'wait';")

this line is in the page_load function.

When I change document.body.style.cursor = 'wait';
to alert("boo!"); , I get the alert. This means that the javascript function is correctly added to the button.

Thanks for you help.
 
Here is the page_load function
Code:
Private Sub Page_Load(ByVal vSender As Object, ByVal vEvent As System.EventArgs) Handles Me.Load
        clsOutilsTrans.TracePerfoONLI("(TAL) LOAD Condition entree habitation", True)

        If Not clsOutilsTrans.EstModePilotage Then
            GererToken()
            GererInitialisations()
            GererContexte()
            GererParametresRecus()
            GererChargementListes()
            GererAffichageChamps()
        Else
            GererInitialisations()
            GererChargementListes()
            GererAffichageChamps()
        End If

        'ajouter l'evenement javascript lors du click du bouton recherche
        Me.btnRecherche.Attributes.Add("onclick", "wait();")
        clsOutilsTrans.TracePerfoONLI("(TAL) LOAD Condition entree habitation", False)

    End Sub
 
Well you seem to be adding the javascript on the load of the page which eliminates that potential issue. However, I can't see why it wouldn't produce the functionality you are wanting. For example, this simple test works fine:
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default1.aspx.vb" Inherits="Default1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="document.body.style.cursor = 'wait';" />
    </div>
    </form>
</body>
</html>


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

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Something weird about this problem is that in another project created in VS2002, the following line works just fine and is called in the pageload function too.

Code:
  Me.btnRechercheOk.Attributes.Add("onclick", "document.body.style.cursor = 'wait';")

Still investigating...
 
I just realized that it does work, but when the cursor is outside the form. Do I have to change the cursor property for every control/element?
 
I just realized that my problem is due to ajax which doesn't raise à postback event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top