0
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();
        }

嗨,前面的代码允许我通过弹出“另存为”对话框一键传输一个文件。

我想通过弹出 2 个“另存为”对话框在点击时传输 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();

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

谢谢你的帮助!

4

2 回答 2

1

好吧,你不能对一个请求给出多个响应。您需要找到一种方法来从浏览器发起两个请求。首先想到的是两个 javascript window.open 调用

于 2010-07-07T18:35:51.850 回答
0

我认为不可能直接实现这一点,但您可以通过解决方法来管理它。

iframes在您的页面上创建两个。一旦用户单击您的按钮,使用 javascript 将srciframe 更改为一个 aspx 页面,该页面服务器每个文件保存一个文件。

我还没有尝试过,但我认为它应该可以工作。

于 2010-07-07T18:35:38.557 回答