当我在按钮的单击事件上写入 Response.write() 时出现错误
Sys.Webforms.PageRequestManagerParserErrorException:收到消息 无法解析来自服务器的信息。导致此错误的常见原因是 当通过调用 Response.Write() 修改响应时,响应 过滤器、HttpModules 或服务器跟踪已启用。详细信息:解析错误 靠近 '
您好,我在更新面板中保留了按钮,但收到此错误
Sys.Webforms.PageRequestManagerParserErrorException: The message received
from the server could 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 '
Hi i have kept button in updatepanel and i am getting this error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应在按钮的事件处理程序中使用 Response.Write。实际上,您根本不应该使用 Response.Write() ,除非您手动处理所有响应生成(然后您也可以使用 ashx 而不是 aspx)。
一种解决方法是在要显示文本的页面上放置一个文字控件,并在按钮单击事件中设置文字的值。
You shouldn't use Response.Write in the event handler for a button. Really you shouldn't use Response.Write() at all unless you're handling ALL of the response generation manually (and then you might as well use an ashx instead of aspx).
One workaround is to place a literal control on the page where you want your text to be displayed and in the button click event set the value of the literal.
updatePanel 是 ajax 的自动方式,不能与 Response.Write() 一起使用,因为它需要在内存上渲染要发送的内容,而不是从页面传递。 Respose.Write()直接将输出发送到客户端,就像直接输出到客户端页面一样,但没有这个页面。因此 updatePanel 上的 Respose.Write() 会抛出异常。
将 Respose.Write() 替换为可能的文字,并将您想要显示的输出放入文字中。
The updatePanel is an automatic way of ajax, and can not work with Response.Write() because is needs to render on memory what is going to send, and not pass from the page. The Respose.Write() send the output to the client directly, is like a direct output to the client page, but without having this page. So the Respose.Write() on updatePanel throw an exception.
Replace the Respose.Write() with probably a literal, and place inside the literal the output that you like to show.
更普遍的原因是,某些防火墙/浏览器插件可以剥离 AJAX 相关的 HTTP 标头值 X-MicrosoftAJAX,从而破坏正常的页面渲染周期。
详细说明请参阅 Telerik 博客 Telerik 网站上的博客文章 但似乎由于公司重组,他们失去了博客服务(希望是暂时的)。因此引用 Bing 缓存:
http://cc.bingj.com/cache.aspx?q=http%3a%2f %2fblogs.telerik.com%2fhristodeshev%2fposts%2f07-06-24%2ffirewalls_writing_asp_net_ajax.aspx&d=4534636468308322&mkt=en-GB&setlang=en-US&w=8ZCg4pTc8CwOHTBDOYwjhsvWm FHYT0tM
More generic reason is that some firewalls/browser plugins can strip AJAX related HTTP header value X-MicrosoftAJAX and thus normal page rendering cycle is broken.
Detailed explanation was available in Telerik blog Blog post on Telerik site but seems due to company reorganization they lost blog service (hope that temporarily). So quote from Bing cache:
http://cc.bingj.com/cache.aspx?q=http%3a%2f%2fblogs.telerik.com%2fhristodeshev%2fposts%2f07-06-24%2ffirewalls_breaking_asp_net_ajax.aspx&d=4534636468308322&mkt=en-GB&setlang=en-US&w=8ZCg4pTc8CwOHTBDOYwjhsvWmFHYT0tM