0
我新的ASP.NET AJAX和我遇到的一个问题。从UpdatePanel中动态生成下载失败,PageRequestManagerParserErrorException
页面使用UpdatePanel和Timer检查批处理队列的新结果。当结果出来,它应该显示的链接来下载文件的结果。
我使用一个中继器格式化的链接,它使用了LinkButton:
<asp:LinkButton ID="linkOutputFile" runat="server" OnCommand="linkOutputFile_Command" CommandArgument='<%# Container.DataItem %>'><%# Container.DataItem %></asp:LinkButton>
中的数据项的wwwroot以外的文件夹中,所以我有这个命令处理程序自动生成下载:
protected void linkOutputFile_Command (object sender, CommandEventArgs e)
{
String strFile = e.CommandArgument as String;
String strExt = Path.GetExtension(strFile).ToLower();
String strSourceFile = Path.Combine(Common.UploadFolder, strFile);
Response.ContentType = "text/plain"; // all results files are text
Response.AddHeader("content-disposition", "attachment; filename=" + strFile);
Response.Buffer = true;
Response.Write(File.ReadAllText(strSourceFile));
Response.End();
}
一切与显示和更新工作正常,但点击链接时,我得到一个PageRequestManagerParserErrorException和细节显示“错误分析近‘XXX’”,其中“XXX”是从文件中的内容。
我相信这些文件正在被正确读取,并且通常这会工作,除了UpdatePanel在对Response.Write的调用时遇到问题。我怎样才能解决这个问题?
我成立了download.ashx,和它的作品,如果我用一个正常的这样一个标签: <%# Container.DataItem %> 谢谢! – 2010-02-08 16:25:36