在我的代码中,我使用JavaScript在ASPX页面上触发window.open()
事件。 I'm在Page_Load()
事件此页的输出文件:将文件写入响应后关闭弹出窗口
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\";");
outputStream.WriteTo(Response.OutputStream);
outputStream.Flush();
outputStream.Close();
Response.Flush();
Response.Close();
后来我想关闭这个弹出窗口。但是因为我改变了我的回复类型,所以我无法在JavaScript中执行window.close()
。它只会附加到提供给用户的文件中。这个线程是最合适的来源,我发现解决我的问题:
Closing window after export to excel
但给出的答案不帮我,所以我基本上卡住。我不想告诉用户手动关闭窗口。你知道如何实现我的目标吗?
这会很好,但我没有使用标准的asp.net UpdatePanel。 – Daniel 2009-03-19 10:41:22