Asp.net Q & A: Floating countdown

Source: Internet
Author: User

Front-end:

<% @ 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 id = " Head1 " Runat = " Server " >
<Title> No title page </title>
<! -- ************************ -->
<SCRIPT type = " Text/JavaScript " >
// <! [CDATA [
VaR Tips; VaR Thetop = 200 /* This is the default height. */ ; VaR Old = thetop;
Function initfloattips (){
Tips = Document. getelementbyid ( ' Floattips ' );
Movetips ();
};
Function movetips (){
VaR Tt = 50 ;
If (Window. innerheight ){
Pos = Window. pageyoffset
}
Else If (Document.doc umentelement & document.doc umentelement. scrolltop ){
Pos = document.doc umentelement. scrolltop
}
Else If (Document. Body ){
Pos = Document. Body. scrolltop;
}
Pos = pos-tips.offsetTop + thetop;
Pos = tips. offsettop + POS/ 10 ;
If (Pos <thetop) Pos = thetop;
If (Pos! = Old ){
Tips. style. Top = POS + " Px " ;
Tt = 10 ;
}
Old = Pos;
SetTimeout (movetips, TT );
}
// !]>
</SCRIPT>
<Style type = " Text/CSS " >
Div # floattips {
Position: absolute;
Border: solid 1px # 777 ;
Padding: 3px;
Top: 250px;
Right: 50px;
Width: 300px;
Background: # cccccc;
Color: white;
}
</Style>
<Script language = " Javascript " Type = " Text/JavaScript " >
Function count_down ()
{
Window. setTimeout ( " Count_down () " , 1000 );
VaR A = Document. getelementbyid ( " Hiddenfield1 " ). Value;

Testday = New Date ();
Today =New Date ();

Time = (testday. gettime ()-Today. gettime ())/( 24 * 60 * 60 * 1000 );
Day = math. Floor (time );
Time = (time-day )* 24 ;
Hour = math. Floor (time );
Time = (time-hour )* 60 ;
Minute = math. Floor (time );
Time = (time-minute )* 60 ;
Second = math. Floor (time );

Show_time.innerhtml = " Remaining Answer time: " + Day + " Days " + Hour + " Hours " + Minute + " Minute " + Second +" Seconds " ;
}
</SCRIPT>
</Head>

<Body onload = " Count_down (); initfloattips (); " >
<Form ID = " Form1 " Runat = " Server " >

<Div id = " Floattips " >
<Div id = " Show_time " Style = " Font-size: 12px; color: # ff6600; " > </Div>
<Asp: hiddenfield id = " Hiddenfield1 " Runat =" Server " />
<! -- ************************* -->
<Table width = " 100% " Border = " 0 " Cellpadding = " 0 " Cellspacing = " 0 " Bgcolor = " # F7f7f7 " >
<Tr>
<TD Height = " 2101 " > </TD>
</Tr>
</Table>
</Form>
</Body>
</Html>

Background:

 Using System;
Using System. Data;
Using System. configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. webcontrols. webparts;
Using System. Web. UI. htmlcontrols;

Public Partial Class _ Default: system. Web. UI. Page
{
Public String A = " 17:40:00 " ; // The time when the database is dynamically read.
Protected Void Page_load ( Object Sender, eventargs E)
{
This . Hiddenfield1.value =;
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.