Timing Mouse Pointer changes

D

Dave

I have a page that, when invoked, it runs a while (~ 15 seconds), then
displays a DataGrid control. What I want to accomplish is to have the mouse
pointer go to 'wait', then after the control displays, return to 'default'.

What happens is the SetWaitPointer() routine changes the cursor to 'wait',
but before the data grid is displayed on the page, 'SetDefaultPointer()'
runs and changes the cursor back to 'default'. This happens about 3 seconds
in, so the user spends 12 seconds looking at a blank window and a default
mouse pointer. I'm imagining that's when he will get that uneasy "Don't
leave me hanging, Dawg" feeling.

I have included a simplified version of the code I use for this. Can anyone
point me to a solution to this? How can I make sure that
SetDefaultPointer() won't fire until the control displays?

Thanks,

Dave

'The platform is Visual Studio 2003, in-line VB.NET
'The functions SetWaitPointer() & SetDefaultPointer() are basically
Javascript:
dim sCommand as string = "document.body.style.cursor = 'wait'; "
response.write("<script language=JavaScript>" & sCommand & "<" &
"/script>")

Sub Page_Load(Sender As Object, E As EventArgs)

SetWaitPointer()

DisplayDatabaseGrid()

SetDefaultPointer()

End Sub
 
C

Cor Ligthert

Dave,

I have not direct the solution because I did a while no JavaScript,

However what you are doing is when I see it right.

Set on the serverside the Wait Cursor (this has no effect on your
clientside)
Initialize
Set on the serverside the default Cursor

Sent the page.

I cannot believe that that is what you want.

Probably you want to set the cursor before the postback from the client to
the server and set it to default when the page is again received on the
client.

As I said I have no snippet for it at hand, maybe somebody else.

Cor
 
D

Dave

Hello, Cor.

The key phrase of yours is "when the page is again received on the client".

I am somewhat of a newbie in web developement. I do not know how to
determine this event. Just playing around, I took the SetDefaultCursor()
out of my code, enclosed it in "<%....%>", and stuck it near the bottom of
all the html code. That worked fine, except that it unexpectedly made the
routine run for 62 seconds instead of 15 seconds.

Anyway, if you know what I should look at to determine when the page is
received by the client, I would appreciate it.

Thanks again,

Dave
 
C

Cor Ligthert

Dave,

Quickly I found this, maybe I look tomorrow, however no promish

Button1.Attributes("onclick") = "document.body.style.cursor='wait'"

However it shows only the wait status there where there are no controls, I
think that I know now how to do it, however I have no time to write that
now.

Cor
 
D

Dave

Thank you, Cor. I have used this method (Button1.Attributes.....) in the
past, but I don't know how to make it work for my present problem.

If I am reading between the lines correctly, you may have a solution
forthcoming. If so, I am patient - I can wait.

I think there is probably some trappable event, but I don't know what it
would be. I know the page knows - because the cursor changes to 'Working in
Background' when you touch the browser's border with the cursor.

Thanks again,

Dave
 
C

Cor Ligthert

Dave,

In my opinion does this one what you ask.
\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes("onclick") = _
"for (var i=0;i < document.all.length; i++)
document.all(i).style.cursor = 'wait';"
Dim str As String
End Sub
///
I hope this helps a little bit?

Cor
 
D

Dave

Well, thank you Cor, but that doesn't do it. I want this to happen without
button clicks.

Someday, I'll either get better at this and figure it out, or I'll browse
onto a page that does it, and maybe by viewing the code or asking the
author, I'll get it.

I appreciate you taking time out for this little problem of mine.

Dave
 
D

Dave

Cor,

This is what I think happens:

First My code. All is in Page_Load(), and all should happen automatically -
the page's only purpose is to hold and display the data grid.

1) Set Cursor Wait
2) Run a 15 second procedure
3) Set Cursor Default

What happens is while the user is waiting for step 2 to complete, step 3
kicks in after only 3 seconds, and the cursor goes back to default for 12
seconds, then the data grid displays.

I think the reason for this is that the actual 15 second procedure takes 3
seconds for the database operation, and it takes the browser 12 seconds to
process the information it gets from the server. But since the server is
done, it sends the reset cursor statement prematurely. If there was some
way I could capture when the browser actually rendered the data grid, I
think I would have it. But I don't know enough client-server programming to
do that. Someday I will ....

Thanks,
Dave
 
C

Cor Ligthert

Dave,

Did you include the code I have in the previous message.
In that is not a setting to default.

In my test it did work.

\\\needs only a button on a form
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes("onclick") = _
"for (var i=0;i < document.all.length; i++)" & _
" document.all(i).style.cursor = 'wait';"
Dim str As String
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Threading.Thread.Sleep(15000)
End Sub
///

Cor
 
D

Dave

Cor,

I thank you very much for trying to help me, but it just isn't going to
work, given my current level of understanding. For right now, I have to
move on to other things.

Once I do get it (weeks, months, or years from now), I will drop you a line
and let you know how. As you are a frequent contributor to this group, I'm
sure it will be easy to find you.

Thanks again,

Dave
 
D

Dave

Cor,

Are you still monitoring this thread?

If so, I have thought of a much simpler way of framing my question.

My .aspx page has only one control on it - a database grid. When this page
opens, Page_Load() invokes a long-running procedure. How can I make it so
that when the window icon in in the upper right hand corner is waving, the
screen has a 'Wait' cursor, and after the icon stops waving, the cursor
changes to 'Default'.

Thanks,
Dave
 
C

Cor Ligthert

Dave,

At least I understood where the problem was when you wrote I have alone a
datagrid on my page.

Put this in the load event.
I tried it. When it does not work for you than reply, than I show tomorrow a
complete sample where it is working with only a datagrid and a select
command in that.

\\\
Dim scriptString As String = _
"javascript:{for (var i=0;i < document.all.length; i++)
document.all(i).style.cursor = 'wait';}"
RegisterOnSubmitStatement("submit", scriptString)
///

I hope this helps a little bit?

Cor
 
D

Dave

Okay, Cor, I did put that code in, but it had no effect.

I don't know why it would have an effect since there is no submit button on
the form, or any other control (that I am aware of) that would submit.

I will look forward to seeing your sample with datagrid and select command.

Thanks again,
Dave
 
C

Cor Ligthert

I don't know why it would have an effect since there is no submit button
on
the form, or any other control (that I am aware of) that would submit.

I will look forward to seeing your sample with datagrid and select
command.
\\\This in the body of the HTML (aspx) page
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 80px; POSITION:
absolute; TOP: 140px"
runat="server" Width="484px">
<Columns>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select "></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</form>
<script>
</body>
///
\\\This in the code
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim scriptString As String = _
"javascript:{for (var i=0;i < document.all.length; i++)
document.all(i).style.cursor = 'wait';}"
RegisterOnSubmitStatement("submit", scriptString)
If Not IsPostBack Then
builddata()
DataGrid1.DataBind()
Else
DataGrid1.DataSource = Session.Item("dt")
End If
End Sub
Private Sub builddata()
Dim dt As New DataTable
dt.Columns.Add("Column1")
For i As Integer = 0 To 9
dt.LoadDataRow(New Object() {i.ToString}, True)
Next
Session.Item("dt") = dt
DataGrid1.DataSource = dt
End Sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles DataGrid1.ItemCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
Threading.Thread.Sleep(5000)
DataGrid1.DataBind()
End Sub
End Class
///

When you push on the select the waitcursor is showed untill it is back. (I
have a set a sleep in it, to let it take some time)

Cor
 
D

Dave

Cor, thank you very much for all your help.

I loaded up your code into a new project, and it works perfectly.

Now I just need to figure out how to use it in an inline (not code-behind),
buttonless environment, and I'll be set.

Thanks again.
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top