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

Change cursor in server script 1

Status
Not open for further replies.

aldrin001

Programmer
Mar 3, 2003
5
BE
I created an asp page that is buffered on the server. Now i wanted to change the cursor to wait when the server is doing a calculation. The calculation can sometimes take 30 seconds because it has to do calculations from 2000 records.
Does anyone does a way to change the cursor.
 
>> I created an asp page that is buffered on the server

Well if you have ASP buffering turned on you can't do anything until your page finishes.

If you have buffering turned off then you can send HTML to the browser before starting your long lived process then after it concludes you can finish sending the remainder of the HTML code.

So you could send the body tag with a style of cursor: wait which will display the hourglass in the browser then have a body onload attribute which sets the cursor to default when the </html> tag is finally sent.
Code:
<body style=&quot;cursor: wait;&quot; 
	onload=&quot;document.body.style.cursor='default'&quot;

-pete

 
You could also make your own wait page (with buffering turned on). The custom wait page would display a message telling the user that the process is running. This wait page would also contain a redirect command to the ASP process page. Since buffering is turned on the wait page would be displayed until the processing page is finished.
 
This is a common problem.
When you click a button on a page, it typically posts the whole page back to the server - and the whole page needs to be sent back to the browser with the results.

However, this does not have to be the case. You CAN call a server function asyncronously (ie. without the current browser page being sent to the server). WHY? Because then you can pop-up a window or frame with an hourglass gif, or a table that fills with a colour or some other way to indicate that things are happening. Then you call the function (asp page with parameters). When it returns, you hide the pop-up window/frame. I am not sure if you can change the cursor shape.

Here are some methods...

1. Use the Page Object DTC. Write a function in server-side code. Add this function to the PageObjectDTC in the EXECUTE list (first tab, lower list).
Now in Client-Side code (i.e. an onclick event of a button) you can call this function via javascript as thisPage.execute.<functionName(parameters)>.
This method uses a java applet. Some users are prevented from running java - so it may fail. Otherwise, it is very easy to use.
.OR.
2. Create a hidden frame. You can cause the frame to refresh via the client-side
<framename>.window.location.href <asppage?parameters>
This will return a web page back to the hidden frame - in which you can include javascript functions. By executing the java code, it can pass values back to your main (visible) page via parent.form type syntax.
This is a but tricky to use (and understand) but it can be used by most browsers.
.OR.
3. If your users are using IE., then you can use the XML DOM facility. This lets you call an ASP page, and the results are returned as XML, rather than HTML. This makes using complex return values somewhat easier to use. In some respects it is easier to use than method 2 above.
4. If you look at the conquerChat facility ( you may see that it uses a variation in the hidden frame. It finds the HEAD tag, and adds a JavaScript Script tag with the source of an ASP page. The browser will immediately fetch the Javascript by calling the identified ASP page. The resulting javascript is fed back into the browser - i.e. with any data that you requested.

The phrase 'When it returns' above depends on the method that you select. Options 1 and 3 (DTC and XML) you get the results following the call - so you hide your 'please wait' message in the same piece of code.

But options 2 and 4 (Hidden Frame/HEAD element rewrite) the return value is a complete HTML or JavasScript chunk. There would have to be something in this returned JavaScript that turns off the 'please wait' message.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top