Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to make a timer function for website using C# MVC. The timer is started using jquery or ajax and the countdown value is calculated on the controller.

Please help me
Thanks

What I have tried:

I didn't get, firstly i designed design. now i looking for coding part.
Posted
Updated 28-Jan-18 19:46pm

1 solution

If you are looking at implementing a timer in jquery then you'll probably need to use the setTimeout function.

jQuery setTimeout() Function Examples — SitePoint[^]

As far as getting the value, you didn't post any controller or view code so probably can't be of much help but assuming you know how to get values from your controller to your view, if you are using a strongly typed model in your view you could just add a property to your model called public int Timer {get;set;} then in your view you would just sue the Timer value from your model in the delay parameter.

If you aren't using a strongly typed model then you can add the timer value to a ViewBag key or something like that to get it from your controller to your model.
 
Share this answer
 
Comments
Ehsan Sajjad 3-Feb-18 13:44pm    
or may be setinterval

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900