加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – Response.Write和UpdatePanel

发布时间:2020-12-15 22:58:01 所属栏目:asp.Net 来源:网络整理
导读:我生成一个vcard,我发送到客户端使用以下代码片段: Response.AddHeader("Content-Disposition",string.Format("attachment; filename={0}",fileNameOnly));Response.ContentType = "text/x-vcard";Response.ContentEncoding = Encoding.GetEncoding("ISO-88
我生成一个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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读