views:

22

answers:

2
protected void Button1_Click(object sender, EventArgs e)
        {
            Response.ContentType = "text/txt";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + "file.txt");
            Response.Write(@"C:\temp.txt");
            Response.End();
        }

Hi, the previous code allows me to transfer one file within one click by popping up the 'Save as' dialog box.

I would like to transfer 2 files within on click by popping up 2 'Save as' dialog boxes

I might have a too simplistic approach because the below doesn't work, it just brings one 'Save as' box

protected void Button1_Click(object sender, EventArgs e)
        {
            Response.ContentType = "text/txt";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + "file.txt");
            Response.Write(@"C:\temp.txt");
            Response.End();

            Response.ContentType = "text/txt";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + "file.txt");
            Response.Write(@"C:\temp.txt");
            Response.End();
        }

Thanks for your help!

+1  A: 

I don't think it's possible to achieve this directly, but you can manage it with a workaround.

Create two iframes on your page. Once the user clicks your button, use javascript to change the src of the iframes to an aspx page which servers up one file each to be saved.

I haven't tried it, but I think it should work.

Mikael Svenson
+1  A: 

Well, you can't give more than one response to a request. You need to work out a way to initiate two requests from the browser. The first thought that comes to mind is two javascript window.open calls

matt-dot-net