Introduction
Timer countdown is very important in our web apps while we are restricting to end user within specified time frame for example apps online Quiz, online survey etc. Here, in this article I am explain in full depth, how to implement Jquery/JavaScript timer count down in our web apps.
Step 1:First of all add following time to start count down while open our MVC web app, here I am adding 2 minutes of time count down.
public ActionResult Index() { if (Session["Rem_Time"] == null) { Session["Rem_Time"] = DateTime.Now.AddMinutes(2).ToString("dd-MM-yyyy h:mm:ss tt"); } ViewBag.Rem_Time = Session["Rem_Time"]; ViewBag.Message = "Modify this template to jump-start your MVC application."; return View(); }Step 2: Add following div in Index page of our MVC apps _layout.cshtml page.
Populating JavaScript Timer Count Down in MVC Web Application
Finally, you can see how populating JavaScript Timer Count Down in MVC Web Application. I hope it will help you all.
what is the use of window.location.href = 'Account/Login';
ReplyDeleteplease explain
When the time duration expires, then it will navigate to desired page.
Deletecould this script be modified so that the timer counts up? if so how?
ReplyDeleteyou need to make changes in method to achieve desired functionality.
Deleteit dosnt work corectly
ReplyDeleteit apears like that
Secs:NaN
can you help me to write it correctly
Check your secs, I think it's not starting correctionally, it is usually used to indicate an error condition for a function that should return a valid number (check for number or cast your value into numeric correctly).
Delete