【发布时间】:2013-02-25 19:43:42
【问题描述】:
所以我有以下场景:
--- Page.aspx ---
UpdatePanel
ListView
UserControl.ascx
--- UserControl.ascx ---
ListView
Button|ID:btnDownloadAttachment
我使用以下方法下载附件:
public void OpenDocument(byte[] AttContent, string fileName, string inExtension)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + inExtension);
Response.AddHeader("Content-Length", AttContent.Length.ToString());
Response.BinaryWrite(AttContent);
}
但由于内容在更新面板中,我收到以下错误:
“Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: 无法解析从服务器接收到的消息。”
【问题讨论】:
-
您无法通过 AJAX 下载文件。
-
@SLaks 我需要更新面板,反正我可以解决这个问题吗?
-
没有。您需要回发。
标签: asp.net user-controls updatepanel parent-child binarywriter