Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。
来源:互联网 发布:知向濂洛之学 编辑:程序博客网 时间:2024/05/17 18:03
Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。
今天在GridView的模板列中要实现一个下载附件的功能,下载的代码如下:
/// <summary>
/// 下载文件
/// </summary>
/// <param name="page">当前页对象</param>
/// <param name="fileName">文件名</param>
/// <param name="fileContext">文件字节流</param>
public static void DownLoadFile(System.Web.UI.Page page, string fileName, byte[] fileContext)
{
page.Response.Buffer = true;
page.Response.Clear();
page.Response.ContentType = "application/octet-stream";
page.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName));
page.Response.BinaryWrite(fileContext);
page.Response.Flush();
page.Response.End();
}
结果一运行,问题来了 Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。错误!
在网上搜罗了半天终于找到答案,一看页面用了 <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:GridView ID="gvList" runat="server" AutoGenerateColumns="false" CssClass="grid"
OnRowDataBound="gvList_RowDataBound" DataKeyNames="ID" AllowSorting="true" OnSorting="gvList_Sorting"
RowStyle-HorizontalAlign="Left" OnRowCommand="gvList_RowCommand">
<Columns>
<asp:CheckBoxField ItemStyle-Width="40" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="序号">
<ItemStyle HorizontalAlign="Center" Width="50"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="标题" DataField="Name" SortExpression="Name"></asp:BoundField>
<asp:BoundField HeaderText="文件状态" DataField="FileStatus" SortExpression="FileStatus">
<ItemStyle Width="60" HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="版本" DataField="VersionNo" SortExpression="VersionNo">
<ItemStyle Width="60" HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="注销原因" DataField="CancelReason">
<ItemStyle Width="150" HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="注销时间" DataField="CancelDate" DataFormatString="{0:yyyy-MM-dd}">
<ItemStyle Width="80" HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="50px"></ItemStyle>
<HeaderTemplate>
注销附件
</HeaderTemplate>
<ItemTemplate>
<asp:Button ID="btnDownload" runat="server" CommandName="DownLoad" CausesValidation="False" CssClass="btnGrid"
Text="下载"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" Width="50px"></ItemStyle>
<HeaderTemplate>
操作</HeaderTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="tip">
暂无记录!</div>
</EmptyDataTemplate>
</asp:GridView>
</asp:UpdatePanel>
发现在gvList_RowDataBound的时候未对下载按钮动态注册,导致了错误的发生,该事件中添加如下代码:
if (e.Row.RowType == DataControlRowType.DataRow)
{
//注册下载按钮的事件
ScriptManager sm = (ScriptManager)this.Page.FindControl("ScriptManager1");
if (e.Row.FindControl("btnDownload") != null)
{
sm.RegisterPostBackControl(e.Row.FindControl("btnDownload"));
}
}
- Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息
- Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息
- Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。
- Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息
- Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息
- 错误:Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息
- JavaScript 运行时错误: Sys.WebForms.PageRequestManagerParserErrorException: 未能分析从服务器收到的消息。
- 错误: Sys.WebForms.PageRequestManagerParserErrorException: 未能分析从服务器收到的消息。
- Sys.WebForms.PageRequestManagerParserErrorException的解决方法
- Sys.WebForms.PageRequestManagerParserErrorException的解决方法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException错误的解决方法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法
- Android应用开发笔记(12):Android应用的自动升级、更新模块的实现 (转载)
- LeetCode之Best Time to Buy and Sell Stock
- 驱动感染技术扫盲(C描述)
- Android Studio试用说明
- C++: Linux上静态库和动态库
- Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。
- tornado 3.0.1 中关于cookie和secure cookie的那点事儿
- ios-获取系统相簿里边的所有照片
- django1.4模板中如何导入js、css等外部文件
- 顶级 PHP 大师的 10 条开发建议
- JUnit4概述
- sql 工具备忘
- JAVA、JS中验证身份证号码、手机号码、电子邮箱的正则表达式
- Linux 多线程编程