回复于和的UpdatePanel [英] Response.Write and UpdatePanel
问题描述
我产生,我用下面的code片段发送到客户端的电子名片:
I generate a vcard that I send to the client using the following code snippet:
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控件在页面上使用的电子名片。不幸的是,根据<一href=\"http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx\"相对=nofollow>更新面板和响应写这并不工作,导致一个错误。
我想知道有一些替代方式的电子名片/文件的内容发送到客户端的浏览器,并将它显示打开/保存对话框中不涉及的Response.Write?
However, I need to use vCards on a page that has the control inside and UpdatePanel. Unfortunately, according to Update panel and Response write this does not work and causes an error. I am wondering what are some alternative ways to send the contents of the vcard/file to the client's browser and have it display "open/save" dialog that don't involve Response.Write?
推荐答案
您不能在异步回发过程中使用的Response.Write
。无论控制执行是code需要被添加为 PostBackTrigger
在更新面板:
You can't use Response.Write
during an asynchronous postback. Whatever control executes that code needs to be added as a PostBackTrigger
in the update panel:
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
您也可以做到这一点在code-后面,如果你preFER:
You can also do it in code-behind, if you prefer:
ScriptManager.GetCurrent().RegisterPostBackControl(Button1);
这篇关于回复于和的UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!