且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在ASP导出不工作后ASP ASP GridView刷新

更新时间:2023-12-03 12:54:22

这是因为您是:
$ b

This is happening because you are:


  1. 清除响应;
  2. 发送Excel文件;
  3. 结束响应。

换句话说,服务器对您请求的回复是发送excel文件。它不会向浏览器发送一批新的HTML,因为您告诉它在发送文件后停止。正如您所观察到的,您的页面不会更改,因为您没有向浏览器发送任何新的HTML。

In other words, the server's reply to your request is to send the excel file. It doesn't send a new batch of HTML to the browser, because you told it to stop after the file was sent. As you have observed, your page doesn't change, because you didn't send your browser any new HTML.

我不相信可以发送文件并将新的HTML发送到浏览器,但我很乐意被证明是错误的。我见过的大多数人尝试这两种方式都涉及到重新绑定和页面刷新,然后对服务器进行类似Ajax的GET调用以获取Excel文件。其他选项包括打开一个新的非常小的窗口,只是进行GET并返回Excel文件,然后在发送后关闭。

I don't believe it's possible to both send a file AND send new HTML to the browser, but I'm open to being proved wrong. Most cases I've seen of people attempting both these things involve a rebind and page refresh first, and then an Ajax-like GET call to the server to get the Excel file. Other options include opening a new, very small window that just does a GET and returns the Excel file, and then closes after it's sent.