473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

count down timer with ASP.NET

missshaikh
Hi all,

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

:(

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>timer</title>
<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
else{
days=0;hours=0;mins=0;secs=0;out="";

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

days=Math.floor(amount/86400);//days
amount=amount%86400;

hours=Math.floor(amount/3600);//hours
amount=amount%3600;

mins=Math.floor(amount/60);//minutes
amount=amount%60;

secs=Math.floor(amount);//seconds

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";
document.getElementById('countbox').innerHTML=out;

setTimeout("GetCount()", 1000);
}
}

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

//-->
</script>

</head>
<body>
<form id="form1" runat="server">

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


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

</body>
</html>


this is my code.

please friends Help me
Nov 12 '07 #1
3 6123
Shashi Sadasivan
1,435 Expert 1GB
Have you tried AJAX .Net components for this?
you can get more info on this as ajax.asp.net

cheers
Nov 12 '07 #2
Have you tried AJAX .Net components for this?
you can get more info on this as ajax.asp.net

cheers
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
kenobewan
4,871 Expert 4TB
This is a client side JS problem, its incidental that you are using asp.net. Normally this type of function called in onload event declared on the body tag. HTH.
Nov 18 '07 #4

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

Similar topics

7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
2
by: HeroinNO.4 | last post by:
Copy the code below and save in a .htm file, for example : 1.htm, then run it in browser, you'll see a cool count down timer ! If it doesn't work, you may open http://www.fillweb.com in IE and...
1
by: HeroinNO.4 | last post by:
Hello guys, sorry for my last version has a little "feature"(MS always call his bug "feature"), and now I fixed it and show the source to you all ! Just as the last version, copy the code below and...
2
by: HeroinNO.4 | last post by:
Hello guys, now the source code updated to November 06, 2006 00:00 GMT,and now I fixed it and show the source to you all ! Just as the last version, copy the code below and save in a .htm file, fox...
1
by: HeroinNO.4 | last post by:
You can open http://www.fillweb.com in IE and View->Source to see the latest version full featured count down timer source code, or you may also copy the code below and save in a "*.htm" file, for...
2
by: HeroinNO.4 | last post by:
Hello everyone! Now the latest version of free count down timer source code is available in http://www.fillweb.com/countdown.htm, you can open it in IE and View->Source to see the latest version...
7
by: HeroinNO.4 | last post by:
Hello guys, free count down timer source code has updated to 06/11/27, you can copy the code below and save in a ".htm" file and run it in a browser support javascript 1.1 or later, or you can open...
2
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form...
22
by: canabatz | last post by:
Hi all! i got a countdown timer for auctions that runing. i got a DIV that refreshs every 4 seconds that DIV is refreshed by ajax ,the file that is refreshed is timer.php for example!! my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.