This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
Displaying Processing Messages, Accessing File Size and Bandwidth, and Debugging ASP | |||||||
Robert Hess | |||||||
Q I am developing an ASP application in which the user enters some information in screen A. After processing this information, I display screen B. But the processing sometimes takes a while, so I want to display a screen between A and B that says "Please wait..." or " Processing....". In the interim, I�ll do the processing while that screen is displayed, then automatically switch to screen B when ready. I want to avoid any client-side scripting, so I need to process the information on the server and pass it to the client when it�s ready. A First of all, you�re lucky a timeout message is not being generated on the client during processing. In the April issue of MSDN Magazine I addressed the issue of unsightly timeout errors popping up while the browser is waiting for a process. With that warning in hand, I can tell you that one way to present an interim screen is to use a frameset in which a very small (1 px by 1 px) frame was connected to the ASP code doing the processing. That ASP code would use the
statement to turn on Keep-Alive for that page. This will maintain the connection to the server for this page without it timing out. In the main frame of the page you would display the "Please wait..." message. Then, when the hidden page finishes its processing, it could return script code to reset the main frame or point the entire frameset to the report page. Of course this assumes the browser can execute whatever script you return. Q Okay, I�ve implemented the solution you suggested, but I�m still having some problems using the frames. Page A submits data to page B for processing. Page B has a frameset with two frames. One has the data that was posted from page A, and the other displays a simple HTML page that says "Please wait while we process your data...." But when the processing is complete in one frame I want to close the "Please wait" frame. Is it possible to close one child frame from another? A From a frameset window, you can�t just close one of the windows. Instead, you have to open a new page with the target set to _top or _parent. This will load a new Web page into the place where the frameset had been defined. Suppose you have a two-frame page, where one frame contains one.html and the other contains two.html. One.html looks like this:
When the user clicks on the link, it would appear to them that the frame containing one.html had closed down, leaving two.html. If you want this to happen when some calculation is completed, you could use something like:
Then you would just have to execute the script code
which would behave as though the user clicked on that link. Q I�m trying to find a way to determine the size of a client-side file before uploading it to the server. JavaScript doesn�t seem to be able to handle this, and CGI.CONTENT_LENGTH only works after the upload, so it really doesn�t help much. I�ve been told that it can be done with ActiveX®, but I can�t find any information about it. A If I read your question correctly, you are trying to use the file upload capability in Microsoft® Internet Explorer. Before uploading the file to the server, you want to report the file size to the server. To do this with regular scripting, you�d have to gain access to the client file system, which is off-limits to Web pages. Q Is there a way to detect the bandwidth of a Web site visitor�s connection? I want to automatically redirect users to either a slow or fast version of my Web site. A If there were a way to automatically detect bandwidth, we wouldn�t be seeing all of those Select Bandwidth links on streaming media playback sites.
to your ASP page, which will dump out all of the data in the headers received by the server session. To determine the user�s bandwidth would require you to find out how fast the client was able to download information from your server. To see an example of this, check out https://computingcentral.msn.com/topics/bandwidth/speedtest.asp. Q In one of my ASP files, I provide data to the ASP by calling a middle-tier DLL. Sometimes the data stream stops in the middle and returns "ASP error: Unexpected Trappable Error." I don�t know how to trap this error. I�m using eight arrays in my page. Does this cause a memory problem? A The error could be in the DLL that you mention, or in your JScript® code. To debug into the DLL, you would need to be the author of this DLL (or have access to the code), and be running it in debug mode. Q I�ve set up a Web page where a user can fill in information, print it, and mail it. But I would like to make this task easier for users, letting them use e-mail. I can do this in an ASP page, but my Web provider doesn�t allow them. A There are a few ways to accomplish this. The easiest is to use a Web server that has mail services installed on it that will let you generate e-mail directly from that server on behalf of the user. As you know, this is not an option many servers allow. But somebody has to generate the e-mail, and if it isn�t the server, then it must be the client.
This would generate a full e-mail message and send it out from the user�s machine (with a warning posted to the user that it was doing this). Q I have an ASP page that builds a listbox of items that are being processed. The page has Submit buttons that allow the user to select the previous and next pages. The code works well except that the current listbox selection can scroll out of view. Is there some way to move the selected item to the top of the listbox? A Well, there�s good news and bad news here. The good news is that Internet Explorer 5.0 will automatically scroll a selection list to the item that has the SELECTED property set. The bad news is that neither Internet Explorer 4.0 nor Netscape Navigator 4.0 will do this.
But this won�t work with Netscape Navigator 4.0 (nor would anything else I tried) and I couldn�t find a solution that did work. |
|||||||
Robert Hess is an engineer in the Microsoft Developer Relations group. He provides ISVs with information to help them develop apps for Microsoft systems software. Send e-mail to webqa@microsoft.com. From the May 2000 issue of MSDN Magazine. |