Sys.WebForms.PageRequestManagerParserErrorException 错误

来源:互联网 发布:js点击li切换div 编辑:程序博客网 时间:2024/05/23 02:00

 
 
Sys.WebForms.PageRequestManagerParserErrorException 错误
最近老是碰到ajax的问题,在同学那要了一个框架,虽然很好用。但是也有它的局限性。
想起以前在学校的ajax控件,但在使用ajax的时候经常出现下面的问题:
Sys.WebForms.PageRequestManagerParserErrorException:The message received from the server
count not be parsed.Common causes for this error are when the response is modified by calls to response.Write(),
response filters,HttpModules,or server trace is enabled.
Details:Error parsing near '|<html>
<head>
在网上搜索了一下,大部分解释是:
在用Response.Redirect()或Response.Write()进行URL带参数的页面重定向时出现如题所示的错误。
Ajax是无刷新的,而使用Response进行带参重定向时需要刷新页面。
解决办法1:
只须在UpdatePanel下设置“asp:PostBackTrigger”的“ControlID”为指定的控件名称即可,如:
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
</Triggers>
但这样做就失去了ajax异步刷新的功能,跟不用没有什么区别。在特定的环境有可能会用到。
解决办法2:
         在返回响应时不用Response对象,
         ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1,this.GetType(),"test","alert('插入成功')",true);

 

原创粉丝点击