以分钟和秒为单位设置计数器 [英] set counter in minutes and seconds
本文介绍了以分钟和秒为单位设置计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在几分钟和几秒钟内创建倒数计时器。 (比如:20:53)
这次减少。就像这个-20:52,20:51,20:50 ....
如何创建这个计时器。
i有创建计时器,但它只显示秒数。
我的代码在这里。
< asp:Timer ID =Timer1runat =serverInterval =2000ontick =Timer1_Tick>
< / asp:计时器>
protected void Timer1_Tick(object sender,EventArgs e)
{
int秒;
if(Convert.ToString(Lable2.Text)!=)
{
seconds = int.Parse(Lable2.Text);
}
其他
{
秒= Convert.ToInt32(60); //在默认计时器中设置一些时间计数
}
Session [timeoutSecond] =(seconds - 1).ToString();
if(seconds> 0)
{
Lable2.Text =(seconds - 1).ToString();
}
其他
{
//Timer1.Enabled = false;
}
}
i必须启动和停止计时器,我什么时候想要。
如何做到这一点。
解决方案
我建议你使用JavaScript计时器:
http://www.w3schools.com/js/js_timing.asp [ ^ ]
你可以从中创建一个完美的倒计时:
http://www.proglogic。 com / code / javascript / time / countdown.php [ ^ ]。
希望我能帮到你!
欢呼,
Marco
如果你有总剩余秒数,比如说tot_seconds
,那么
int seconds = tot_seconds% 60 ;
int minutes = tot_seconds / 60 ;
参考下面的文章。
需要创建倒计时时钟/计时器,天,小时和小时。可能吗? [ ^ ]
用于网页的JavaScript倒计时/计时定时器/时钟/收报机小工具 [ ^ ]
asp.net中的倒数计时器 [ ^ ]
这些可以帮助你
i have to create countdown timer in minutes and seconds. ( like: 20:53)
this time decrease.like this -20:52,20:51,20:50....
how to create this timer.
i have create timer,but it is displaying only seconds.
my code is here.
<asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" > </asp:Timer>
protected void Timer1_Tick(object sender, EventArgs e) { int seconds; if (Convert.ToString(Lable2.Text) != "") { seconds = int.Parse(Lable2.Text); } else { seconds = Convert.ToInt32(60);//set some time count in default timer } Session["timeoutSecond"] = (seconds - 1).ToString(); if (seconds > 0) { Lable2.Text = (seconds - 1).ToString(); } else { //Timer1.Enabled = false; } }
i have to start and stop the timer ,when ever I want.
how to do this also.
解决方案
I''d suggest you to use a JavaScript timer:
http://www.w3schools.com/js/js_timing.asp[^]
You can create a perfect countdown out of it:
http://www.proglogic.com/code/javascript/time/countdown.php[^].
Hope I was able to help you!
cheers,
Marco
If you have total remaining seconds, saytot_seconds
, then
int seconds = tot_seconds % 60; int minutes = tot_seconds / 60;
Hi,
refer below articles.
Need to create a countdown clock/timer, days, hours and miniutes. Possible?[^]
JavaScript Countdown/Count-up Timer/Clock/Ticker Widget for Web Pages[^]
Countdown timer in asp.net[^]
these could help you.
这篇关于以分钟和秒为单位设置计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文