Dear friends
i am using this code to sow a countdown timer in an online exam project :
Default.aspx page coding
Interval="1000" OnTick="timer1_tick">
runat="server" UpdateMode="Conditional">
Default.aspx.cs page coding
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!SM1.IsInAsyncPostBack)
Session["timeout"] = DateTime.Now.AddMinutes(120).ToString();
}
protected void timer1_tick(object sender, EventArgs e)
{
if (0 > DateTime.Compare(DateTime.Now,DateTime.Parse(Session["timeout"].ToString())))
{
lblTimer.Text = "Number of Minutes Left: " +((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString();
}
}
}
now i wanted to know how i show time into minutes and second format , because this coding only show minutes 10 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 19, 2014, 6:04 AM
Shamkant sapkalePosted May 18, 2016, 3:33 AM
Nitin SharmaPosted Mar 20, 2014, 8:08 AM
Stephan SherePosted Mar 19, 2014, 10:57 PM
TimeSpan TimeLeft = Timeout.Subtract(DateTime.Now);
Console.WriteLine("Time remaining: {0} minutes {1} seconds", TimeLeft.TotalMinutes, TimeLeft.Seconds);
TimeLeft.TotalMinutes = 1
.Seconds to show seconds left in the current minute.
.TotalSeconds to show the total seconds overall.
Vs:
TimeLeft.Hours = 1
TimeLeft.Minutes = 59
VulpesPosted Mar 19, 2014, 7:03 PM
Stephan SherePosted Mar 19, 2014, 6:44 PM
Nitin SharmaPosted Mar 19, 2014, 6:40 AM
i hope u will guide me in future
thanks
VulpesPosted Mar 19, 2014, 5:52 AM
Nitin SharmaPosted Mar 19, 2014, 5:47 AM
please help me
VulpesPosted Mar 18, 2014, 10:39 AM