我怎样才能有一个ASCX回传,并自动刷新自己每隔X秒? [英] How can I have an ascx postback and refresh itself automatically every X seconds?

查看:255
本文介绍了我怎样才能有一个ASCX回传,并自动刷新自己每隔X秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到数据源与经常变化的数据的ascx控件。是否有一个快速的方法有一个ascx控件回发,重新绑定,并刷新自己每隔X秒。该ascx控件是一个更新面板。

I have an ascx control bound to a datasource with frequently changing data. Is there a quick way to have an ascx control postback, rebind and refresh itself every X seconds. The ascx control is in an update panel.

推荐答案

既然你已经在使用它从AJAX工具包使用一个定时器控件:

Use a timer control from the AJAX toolkit since you are already using it:

<asp:Timer ID="tmrPolling" runat="server" Interval="10000" ontick="tmrPolling_Tick"></asp:Timer>

触发器添加到您的更新面板,如:

Add a trigger to your update panel like:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="tmrPolling" EventName="Tick" />
</Triggers>

然后就贯彻落实 tmrPolling_Tick 处理程序:

protected void tmrPolling_Tick(object sender, EventArgs e)
{
    // Change your update panel controls and data here.
}

不要将更新面板的内容区域中添加计时器。

Do not add the timer within your update panel content area.

这篇关于我怎样才能有一个ASCX回传,并自动刷新自己每隔X秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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