By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,284 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,284 IT Pros & Developers. It's quick & easy.

count down timer with ASP.NET

P: 43
Hi all,

i need the count down timer when button click the timer start and count down work on


i have one timer which is on JavaScript that run page onload . but i need the Button click my code is here...

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">

dateFuture = new Date(2007,10,12,18,43,48);

//nothing beyond this point
function GetCount(){

dateNow = new Date(); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;

// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now !";
// date is still good

amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs





if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" "+((hours!=1)?":":"")+" ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" "+((mins!=1)?" ":"")+", ";}
out += secs +" seconds";

setTimeout("GetCount()", 1000);

//window.onload=function(){GetCount();}//call when everything has loaded


<form id="form1" runat="server">

<div id="countbox" ></div>

<asp:Button ID="Button1" runat="server" Text="Start " OnClick="Button1_Click"/>


this is my code.

please friends Help me
Nov 12 '07 #1
Share this Question
Share on Google+
3 Replies

Shashi Sadasivan
Expert 100+
P: 1,435
Have you tried AJAX .Net components for this?
you can get more info on this as

Nov 12 '07 #2

P: 43
Have you tried AJAX .Net components for this?
you can get more info on this as

i can not use Ajax. on my online server where i upload my site there is no accessible for Ajax dll files
Nov 18 '07 #3

Expert 2.5K+
P: 4,871
This is a client side JS problem, its incidental that you are using Normally this type of function called in onload event declared on the body tag. HTH.
Nov 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.