UpdatePanel 中的计时器

编程入门 行业动态 更新时间:2024-10-25 00:27:27
本文介绍了UpdatePanel 中的计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 asp:Timer 的 asp:UpdatePanel.这些位于主/内容页面中.代码如下:

I have an asp:UpdatePanel with an asp:Timer. These are in a Master/Content Page. The code is below:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"></asp:Timer>
    </ContentTemplate>
</asp:UpdatePanel>

但是当计时器触发时,我收到以下错误:

But when the timer fires, I get the folowing error:

Microsoft JScript 运行时错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息.此错误的常见原因是通过调用 Response.Write()、响应过滤器、HttpModules 或启用服务器跟踪来修改响应.详细信息:在 ' 附近解析错误

这适用于独立的 Web 表单,但不适用于带有母版页的内容页面.

Microsoft JScript runtime error: 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 '

This works in a standalone web form, but not in a content page with a master page.

谁能解释一下解决方法?

Can anyone explain a fix for this?

在此先感谢您的帮助!!

Thanks in advance for any help!!

推荐答案

UpdatePanel 中有 Timer 控件有什么具体原因吗?

Is there a specifc reason why you have the Timer control in the UpdatePanel?

每次我需要使用 Timer 控件来引起 UpdatePanel 刷新时,我都会像下面这样设置它并且它与 MasterPages 一起工作得很好:

Every time I have needed to use a Timer control to cause an UpdatePanel refresh, I have set it up like the following and it works fine with MasterPages:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <Triggers>
        <asp:AsyncPostBackTrigger  ControlID="Timer1" EventName="Tick" />
    </Triggers>
    <ContentTemplate> 
        <!-- your content here, no timer -->
    </ContentTemplate> 
</asp:UpdatePanel> 

<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer> 

使用 Trigger 使 UpdatePanelTick 事件刷新.如果可能,您只想在 UpdatePanel 中嵌入内容.

Use the Trigger to cause the UpdatePanel to refresh from the Tick event. You only want to embed content in your UpdatePanel if possible.

这篇关于UpdatePanel 中的计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-28 18:42:31,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计时器   UpdatePanel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!