views:

108

answers:

2

How can i show a Save as window in asp.net and C#...

This is similar to the one that opens for uploading but that window is the open file...

I am not looking to save only one file...like

Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);

can i make it ung ajax... please help... samples or suggestions..

thanks

+3  A: 

As far as I know you don't have any way of interacting with the file system using javascript from inside the browser. I would imagine that this would be a fairly large security hole if you could. The best I can suggest is to package up your files in a zip file then send that in a response with the content disposition set to attachment, then let the browser handle it for you.

tvanfosson
This doesn't answer his question - he wants to have a single page download several files, prompting for each one. If you don't think it's possible, just say so.
egrunin
A: 

In your page:

<iframe src="getFile.aspx?id=1"/>
<iframe src="getFile.aspx?id=2/>

Then inside getFile.aspx

Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
Response.BinaryWrite(fileContents);

(Note: never tried this myself...)

egrunin
This would open multiple "Save as" dialogs, one for each file, which is what he is trying to avoid -- see his response to the comment on the question.
tvanfosson