前台:

<%@ 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>无标题页</title>
<!--***********开始*************-->
<script type="text/javascript">
//<![CDATA[
var tips; var theTop = 200/*这是默认高度,越大越往下*/; var old = theTop;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
};
function moveTips() {
var tt=50;
if (window.innerHeight) {
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.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(a);
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="剩余答题时间:"+day+""+hour+"小时"+minute+""+second+"";
}
</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></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>

后台:

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 = "2012/3/9 17:40:00"; //此处动态读取数据库时间
protected void Page_Load(object sender, EventArgs e)
{
this.HiddenField1.Value = a;
}
}



 posted on 2012-03-09 12:09  纳米程序员  阅读(869)  评论(0编辑  收藏  举报