简体   繁体   English

如何在ASP.net上正确使用启动和停止计时器?

[英]How to properly use start and stop timer on ASP.net?

I am having problems on using a timer on ASP.Net I am unable to start the timer after stopping it. 我在使用ASP.Net上的计时器时遇到问题,在停止计时器后无法启动计时器。

I am calling the functions from code behind using 我从后面的代码中调用函数

ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "startTimer();", true);

Gives me this error. 给我这个错误。 Screenshot below.. 屏幕截图如下。

在此处输入图片说明

My main problem is that I need to used the timer like this.. Do something > Start time > Do something on Tick + Stop time > Do something > Start time But I can't because I cannot restart the timer when I stopped it. 我的主要问题是我需要像这样使用计时器。做一些事情>开始时间>在滴答滴答+停止时间上做某事>开始时间,但是我做不到,因为我无法在停止计时器时重新启动它。

<asp:Timer ID="tmrMain" runat="server" Interval="1000" EnableViewState="False"></asp:Timer>

Because $ is Jquery Object, find is method. 因为$是Jquery对象,所以find是方法。

So you might use dot to call method 所以你可能会使用点号来调用方法

$.find('tmrMain');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM