Response.Write的问题 [英] Problem with Response.Write

查看:98
本文介绍了Response.Write的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



当我尝试将数据导出到Excel并将文件发送到客户端时,我遇到了问题。



Hi everybody,

I get a problem when I try to export data to excel and send file to client.

string data = hidden_data.Value;
data = HttpUtility.UrlDecode(data);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Data.xls");
Response.Charset = "UTF-8";
Response.ContentType = "application/excel";
HttpContext.Current.Response.Write(data);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();

_btnExport.Enabled = false;
radList.Enabled = false;
lblState.Text = "Done";





发送excel文件后,我希望禁用_btnExport和radList,并且lblState显示Done。我收到excel文件并正常打开,但_btnExport和radList仍然启用,lblState什么也没显示。



非常感谢。



After transmitting excel file, I want _btnExport and radList to be disabled and lblState to display "Done". I receive excel file and open it normally, but _btnExport and radList are still enabled, lblState display nothing.

Many thanks.

推荐答案

Response.End()之后没有生命 - https://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx [ ^ ]

在您的情况下,唯一发回客户端的是包含excel文件的数据...至于你的按钮,它保持以前的状态......
There is no life after Response.End() - https://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx[^]
In your case the only thing sent back to the client is the data containing the excel file...As for your button, it keeps its previous state...


这篇关于Response.Write的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆