Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Countdown timer in asp.net
Rahul Lakshakar
Mar 30 2017 1:26 PM
364
Reply
i created a count down timer, but i am not getting how to show hour also it just showing seconds and minutes. Can any one guide me please...
My code is:
protected void Page_Load(object sender, EventArgs e)
{
if (!SM1.IsInAsyncPostBack)
{
Session["timeout"] = DateTime.Now.AddSeconds(120).ToString();
}
}
protected void timer1_tick(object sender, EventArgs e)
{
if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString())))
{
lblTimer.Text = string.Format("Time Left: 00:{0}:{1}",
((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString(),
((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).Seconds).ToString());
}
else
{
timer1.Enabled = true;
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
how to show summary in mvc with views
How to call javascript when hot key is pressed?