> I have a button which kicks off the generation of a report after which
> the file will be downloaded. The report generation can take a long
[quoted text clipped - 23 lines]
>
> - Show quoted text -
You can't register RegisterStartupScript, because you already sent a
file to HTTP response...
Remove the following code:
/*
Response.AppendHeader("content-disposition", "attachment;
filename=<filename>");
Response.WriteFile(<filename>);
Response.Flush();
*/
and modify your RegisterStartupScript as per
Page.RegisterStartupScript("ToggleWait",
"<script>javascript:spnMessage.style.display = \"none
\";window.open('<filename>');</script>");
It should hide the spnMessage span tag and open the file in a new
window. If you like to force a Save As window to be shown, you need to
have another page Download.aspx where you can have
Response.AppendHeader("content-disposition", "attachment;
filename=<filename>");
Response.WriteFile(<filename>);
Response.Flush();
Then open that page using window.open('Download.aspx?
filename=<filename>');
Should work, I think.
MJP - 10 Jun 2007 12:47 GMT
Thanks Alexey, that does work.
However, I of course now need to close the window that I open to run
Download.aspx after the file has been written to the HTTP response,
and since RegisterStartupScript won't work after writing the file, I
essentially still have the same problem....
> > I have a button which kicks off the generation of a report after which
> > the file will be downloaded. The report generation can take a long
[quoted text clipped - 57 lines]
>
> - Show quoted text -
Alexey Smirnov - 10 Jun 2007 13:59 GMT
> Thanks Alexey, that does work.
>
> However, I of course now need to close the window that I open to run
> Download.aspx after the file has been written to the HTTP response,
> and since RegisterStartupScript won't work after writing the file, I
> essentially still have the same problem....
I think that when you have a content-disposition=attachment and user
has selected Save button, the popup window will be closed
automatically.