Here is a code sample that should demonstrate the technique of using Response.Buffer and Response.Flush() to simulate a reload. This sample only supports browsers that understand document.all; the server-side methods are here, and you can enhance it however you like to support other browsers (e.g. document.getElementById for Netscape 6+).
<% Response.Buffer = True %> <html> <head> <title>Buffer test</title> </head> <body> <script> <!-- if (document.all) { document.write("<span id=w>Please"); document.write(" wait...</span>"); } //--> </script> <% Response.Flush() %> <% ' put your long-running processes here. ' this should be enough to demonstrate: for i = 1 to 1000000 x = x + 1 next %> <script> <!-- if (document.all) { document.all("w").style.display = 'none'; } //--> </script> </body> </html> |
Note that Response.Flush() should be followed by a closing ASP delimiter. If you use code like the following, the Flush() doesn't actually apply until the closing ASP delimiter is encountered, which means you won't see your message at all:
<% Response.Buffer = True %> <script> <!-- if (document.all) { document.write("<span id=w>Please"); document.write(" wait...</span>"); } //--> </script> <% Response.Flush() ' put your long-running processes here. ' this should be enough to demonstrate: for i = 1 to 1000000 x = x + 1 next %> <script> <!-- if (document.all) { document.all("w").style.display = 'none'; } //--> </script> |
This is all you will need to change to fix it:
<% Response.Buffer = True %> <script> <!-- if (document.all) { document.write("<span id=w>Please"); document.write(" wait...</span>"); } //--> </script> <% Response.Flush() %> <% ' put your long-running processes here. ' this should be enough to demonstrate: for i = 1 to 1000000 x = x + 1 next %> <script> <!-- if (document.all) { document.all("w").style.display = 'none'; } //--> </script> |