Link to home
Start Free TrialLog in
Avatar of ayc8
ayc8

asked on

redirect page After writing out response in excel

I have a html file containing a form that allows user to enter start date and end date that are relevant for retrieiving a recordset.  When the user click on the submit button on the form, a wait message will be displayed and then the data is submitted to an ASP page that process the request by querying the database using the supplied parameters of dates.   In that ASP page the response contenttype has been changed to application/vnd.ms-excel so that the recordset can be written out in excel format.  As a result, a diaglog box always appears asking user if they want to save/open the file (or cancel the transaction).   However, when the diaglog box appears, the browser is still showing the wait message of the html file that calls the ASP page.   Is there anyway to redirect the page after the save diaglog box appears so that the user won't see the wait message any longer?
Avatar of bluV11t
bluV11t
Flag of Norway image

I guess you could use a javascript with a timeout to redirect the page in lets say 5 seconds. Of course the page will always redirect after 5 seconds but I don't think it will interfere with the excel file. Put this in  the head tag of your wait message page:
<script language=javascript>
function fnRedir(){
location.href='url_of_page_to_redirect_to';
}
</script>
 
 
//Put this into the onClick event of the button showing the wait message or the (javascript) function showing the wait message:
 
timerID = setTimeout('fnRedir()', 5000);

Open in new window

Avatar of ayc8
ayc8

ASKER

Hi bluV11t:
thank you very much for your quick reply. However, what I was hoping to accomplish is that  once the downloading processing is complete in the ASP page that renders the response in excel, the calling page (the html page with the wait message) will refresh itself  so that the wait message will not be there any more. I have tried doing a Response.Redirect (back to the calling page) in the ASP page, but that does not do the trick (It works if I put this before Response.Flush() at the end of this page, but the page won't render the response). I have even tried using javascript by attaching an onload event  to the ASP page so that the document location will be changed back to the calling page to the ASP page. That code didn't seem to execute. It seems that once I set the response header to application/vnd.ms-excel, any javascript code is ignored. Any idea what I can do to fix this?
Did you try Response.Flush() after binarywriting the excel and then add new header (text/html) and some html after that? If that works i think you could add some javascript on the asp page to remove the waiting message on the html page... It sounds like a crazy idea, I'll have to test it at work tomorrow :-D
ASKER CERTIFIED SOLUTION
Avatar of bluV11t
bluV11t
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial