如何写更新面板内的Response.Write [英] how to write response.write within update panel

查看:119
本文介绍了如何写更新面板内的Response.Write的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话的函数,而里面Homescroll.ascx.cs从Homescroll.ascx

i am calling a function which is inside Homescroll.ascx.cs from Homescroll.ascx

所以我写了一篇关于Homescroll.ascx作为
 <%的Response.Write(滚动()); %>

so i wrote on Homescroll.ascx as <% Response.Write(scroll()); %>

不过,这一切都是在更新面板,我收到错误信息。
所以他们是任何其他方式来调用homescroll.ascx到homescroll.ascx.cs功能,而不是回复于();

but all this is in update panel,and i am getting errors. so is their any other way to call function from homescroll.ascx to homescroll.ascx.cs,instead of response.write();

推荐答案

&LT;%=滚动()%&GT; 将工作在一个UpdatePanel,但&LT;%的Response.Write(滚动())%方式&gt; 不会

<%= scroll() %> will work in an UpdatePanel, but <% Response.Write(scroll()) %> won't.

与普遍看法相反,&LT;%=%&GT; 显示-EX pressions 的不precisely意思的Response.Write ,不喜欢他们在ASP经典一样。他们都在呈现阶段执行。所不同的是显示-EX pressions写入的HtmlTextWriter 传递给渲染功能&MDASH;不是直接到Response对象。通常情况下这并没有任何区别。除非你使用的UpdatePanel,需要捕捉你的ContentTemplate的输出时,使之能连接code在其特殊格式的输出。如果你调用的Response.Write 直接,你绕过的UpdatePanel和陷入困境的响应进行编码,使其无法在客户端进行解析。

Contrary to popular belief, <%= %> displaying-expressions don't precisely mean Response.Write, not like they did in asp classic. They both execute during the render phase. The difference is that displaying-expressions write to the HtmlTextWriter passed to the render function—not directly to the Response object. Normally this doesn't make any difference. Except when you're using UpdatePanel, which needs to capture the output of your ContentTemplate, so that it can encode the output in its special format. If you call Response.Write directly, you bypass the encoding performed by UpdatePanel and mess up the response so that it can't be parsed on the client side.

当你这样做时发生的错误是不寻常的帮助:

The error that occurs when you do this is unusually helpful:

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.

的UpdatePanel的作者<一个href=\"http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx\"相对=nofollow>提供的解决方法在他的博客的。

The author of UpdatePanel provides workarounds on his blog.

这篇关于如何写更新面板内的Response.Write的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆