asp.net – Response.Write和UpdatePanel

生成一个vcard,我发送到客户端使用以下代码片段:
response.addheader("Content-disposition",string.Format("attachment; filename={0}",fileNameOnly));
Response.ContentType = "text/x-vcard";
Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
Response.Write(vCard.ToString());
Response.End();

但是,我需要在一个内部控制页面和UpdatePanel中使用vCard.不幸的是,根据Update panel and Response write这不行,导致错误.
我想知道有什么办法可以将vcard / file的内容发送到客户端的浏览器,并显示不包含Response.Write的“打开/保存”对话框?

解决方法

在异步回发期间不能使用Response.Write.无论控制执行,代码需要作为PostBackTrigger添加到更新面板中:
<Triggers>        
    <asp:PostBackTrigger ControlID="Button1" />
</Triggers>

您还可以在代码隐藏中执行,如果您愿意:

ScriptManager.GetCurrent().RegisterPostBackControl(Button1);

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...