Paste the following code in header  . .

<div id=”timelabel”></div>

<script type=”text/javascript”>

var leave = <%=seconds %>;
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=day + ” days   “+hour + “:”+minute+”:”+second;

leave=leave-1;
document.getElementById(“timelabel”).innerText=remain;
}

</script>

</body>

</html>

————————

Code Behind . . .

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;
namespace tests{
public partial class _Default : System.Web.UI.Page

{

public double seconds;

protected void Page_Load(object sender, EventArgs e)

{

seconds = (GetEndTime() – GetStartTime()).TotalSeconds;

}

private DateTime GetStartTime()

{            return DateTime.Now;        }

private DateTime GetEndTime()        {            return new DateTime(2011, 8, 23, 8, 10, 0);        }

}

}

Thank you . .

Advertisements