如何使计时器刻度事件在所有td中同时运行 [英] how to make timer tick event run simultaneously in all td's

查看:103
本文介绍了如何使计时器刻度事件在所有td中同时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页上有9个td,每个td有9个更新面板和9个asp计时器

这里当我加载页面时,每个计时器的计时器刻度事件经过很长时间后逐个发生暂停。

这里我希望每个计时器的计时器滴答声不是一个接一个地同时发生。

解决方案

设置所有计时器间隔时间相同,以便它同时打勾



< asp:ScriptManager ID =   ScriptManager1 runat =   server >  < /   asp:ScriptManager  >  
< table>
< tr>
< td align = right class = style9 >
< asp:UpdatePanel ID = UpdatePanel1 runat = server >
<触发器>
< asp:AsyncPostBackTrigger ControlID = Timer1 EventName = 勾选 />
< / 触发器 >
< ContentTemplate>
< asp:计时器ID = Timer1 runat = server Interval = 1000 ontick = Timer1_Tick > < / asp:Timer >
< / ContentTemplate >
< / asp:UpdatePanel >
< / td < span class =code-keyword>>
< / tr >
< / table >





背后的代码

  protected   void  Timer1_Tick( object  sender,EventArgs e)
{
// 做点什么
}





希望这会有所帮助:)


Quote:

启动方法不存在请告诉如何使用启动merhod





首先,回答评论中提出的疑问。

MSDN清楚地说:



Quote:

自Web页面呈现以来或自上一个Tick事件以来Interval属性中指定的毫秒数时,就会引发Tick事件。







可以尝试第一个解决方案中的建议。但是想让updatemode有条件。对于所有具有相同间隔的TD,如下所示。



< asp:updatepanel id =UpdatePanel1runat =serverchildrenastriggers = falseupdatemode =条件xmlns:asp =#unknown> 
< contenttemplate>
//要更新的内容
< / contenttemplate>
< triggers>
< asp:asyncpostbacktrigger controlid =Timer1/>
< /触发器>
< / asp:updatepanel>
< asp:timer id =Timer1runat =serverinterval =1000ontick =Timer1_Tickxmlns:asp =#unknown> < / ASP:计时器>


i have nine td's on my webpage with nine update panel's on every td and with nine asp timer
here when i load the page, timer tick event of every timer occur one by one after a long pauses.
here i want timer tick of every timer to occur simultaneously not by one by one.

解决方案

set all your timers Interval the same so that it will tick simultaneously

 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<table>
<tr>
<td align="right" class="style9">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                    </Triggers>
                    <ContentTemplate>
                       <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick"></asp:Timer>
                    </ContentTemplate>
                    </asp:UpdatePanel>
</td>
</tr>
</table>



on the code behind

protected void Timer1_Tick(object sender, EventArgs e)
   {
    //do something
   }



hope this will help :)


Quote:

start method doesn't exist pls tell how to use start merhod



First , answering for the doubt raised in the comment.
MSDN clearly says :

Quote:

The Tick event is raised when the number of milliseconds specified in the Interval property has elapsed either since the Web page was rendered or since the previous Tick event.




Can try the suggestion in the first solution .But would like to have the updatemode conditional . Something like below for all the TDs with same interval.

<asp:updatepanel id="UpdatePanel1" runat="server" childrenastriggers="false" updatemode="Conditional" xmlns:asp="#unknown">
        <contenttemplate>
           //Content to Update
        </contenttemplate>
        <triggers>
            <asp:asyncpostbacktrigger controlid="Timer1" />
        </triggers>
</asp:updatepanel>
 <asp:timer id="Timer1" runat="server" interval="1000" ontick="Timer1_Tick" xmlns:asp="#unknown"> </asp:timer>


这篇关于如何使计时器刻度事件在所有td中同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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