TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
adam gills
NA
65
14.3k
Set timer on Start botton click
Jan 28 2017 12:01 AM
Hi,
I build a timer which is start on click button and stop after 10 minutes.
I want to know that if click on start button during timer running then its restart from 0,
but timer not reset .
int minremain =600000;
private void timer1_Tick(object sender, EventArgs e)
{
minremain = minremain - 60;
string Sec = string.Empty;
string Min = string.Empty;
if (minremain <= 0)
{
lbltimer.Text = "";
timer1.Stop();
return;
}
else
{
var timeSpan =TimeSpan.FromMilliseconds(Convert.ToDouble(minremain));
var seconds = timeSpan.Seconds;
var minutes = timeSpan.Minutes;
if (seconds.ToString().Length.Equals(1))
{
Sec = "0" + seconds.ToString();
}
else
{
Sec = seconds.ToString();
}
if (minutes.ToString().Length.Equals(1))
{
Min = "0" + minutes.ToString();
}
else
{
Min = minutes.ToString();
}
string Totaltime = "Remaing Time: " + Min + ":" + Sec;
lbltimer.Text = Totaltime;
}
private void btnstartrefresh_Click(object sender, EventArgs e)
{
timer1.Start();
}
So please tell me how to reset timer from start position.
Reply
Answers (
3
)
Difference between Response.Redirect and Server.Transfer?
pagination in mvc without using entity framework