Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<body>
    <form id="form1"  runat="server">
    <div>
    <div id="timelabel"></div>
 <script type="text/javascript">
// var leave =<%=seconds %>;
var leave=0;

CounterTimer();
var interv=setInterval(CounterTimer,1000);

function CounterTimer()
{
var day = Math.floor(leave / ( 60 * 60 * 24))
var hour = Math.floor(leave / 3600) - (day * 24)
var minute = Math.floor(leave / 60) - (day * 24 *60) - (hour * 60)
var second = Math.floor(leave) - (day * 24 *60*60) - (hour * 60 * 60) - (minute*60)

hour=hour<10 ? "0" + hour : hour;
minute=minute<10 ? "0" + minute : minute;
second=second<10 ? "0" + second : second;

var remain=hour + ":"+minute+":"+second;
leave=leave+1;

document.getElementById("timelabel").textContent =remain;
}

</script>
    </div>
    </form>
</body>

my this code is postbacking when page loads, what can i do to do not refresh the counter
Posted
Updated 9-Jan-12 21:59pm
v2

1 solution

You could try and go throughpartial page postback (for your other controls).
See this article[^].

There are some walkthroughs available at the end of the article.
 
Share this answer
 

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