download / write to browser.....help!!!

G

Guest

I have an asp.net page. Which has links to few files.

When a user clicks a link, I open a new window and execute a download.aspx
file which writes the content of that file into the browser so that user can
save it in a new window. I'm doing it with the following code....

Response.AddHeader("Content-Disposition", "attachment; filename=" +
this._fileName);
Response.ContentType = "Application/octet-stream";
Response.WriteFile(actualPath);
Response.Flush();
Response.End();

When the file is downloaded the window stays open... How can I close this
window?

Thnx
 
C

Craig Deelsnyder

mavrick101 said:
I have an asp.net page. Which has links to few files.

When a user clicks a link, I open a new window and execute a download.aspx
file which writes the content of that file into the browser so that user can
save it in a new window. I'm doing it with the following code....

Response.AddHeader("Content-Disposition", "attachment; filename=" +
this._fileName);
Response.ContentType = "Application/octet-stream";
Response.WriteFile(actualPath);
Response.Flush();
Response.End();

When the file is downloaded the window stays open... How can I close this
window?

Thnx

Well, I'm not sure there's any easy way, as you can't spit out
javascript in download.aspx. Why not use a hidden iframe for download
instead? Works pretty well; just put a hidden iframe in your main page.
Then when a user clicks a file link, set the source of the iframe to
the URL of the clicked link, using Javascript to do so. Google around
if you need more info....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top