当前位置:编程学习 > C#/ASP.NET >>

急求,怎么在服务端写一个 基于asp.net 的显示动态时间的ajax程序,就是一个label控件,显示服务器端时间

急求,怎么在服务端写一个 基于asp.net 的显示动态时间的ajax程序,就是一个label控件,显示服务器端时间,怎么添加到已经弄好的一个页面?
追问:这个不用那个xmlhttprequest那个对象吗?急求
答案:动态显示服务器时间比较复杂,代码比较多。
我有一个例子,需要的话可以直接传文件。
其他:看看这个是不是可以
<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>无标题文档</title> 
<script> 
function tick() { 
var hours, minutes, seconds, xfile; 
var intHours, intMinutes, intSeconds; 
var today, theday; 
today = new Date(); 
function initArray(){ 
this.length=initArray.arguments.length 
for(var i=0;i<this.length;i++) 
this[i+1]=initArray.arguments[i] } 
var d=new initArray( 
"星期日", 
"星期一", 
"星期二", 
"星期三", 
"星期四", 
"星期五", 
"星期六"); 
theday = today.getYear()+"年" + [today.getMonth()+1]+"月" +today.getDate() + d[today.getDay()+1]; 
intHours = today.getHours(); 
intMinutes = today.getMinutes(); 
intSeconds = today.getSeconds(); 
if (intHours == 0) { 
hours = "12:"; 
xfile = "午夜"; 
} else if (intHours < 12) { 
hours = intHours+":"; 
xfile = "上午"; 
} else if (intHours == 12) { 
hours = "12:"; 
xfile = "正午"; 
} else { 
intHours = intHours - 12 
hours = intHours + ":"; 
xfile = "下午"; 
} 
if (intMinutes < 10) { 
minutes = "0"+intMinutes+":"; 
} else { 
minutes = intMinutes+":"; 
} 
if (intSeconds < 10) { 
seconds = "0"+intSeconds+" "; 
} else { 
seconds = intSeconds+" "; 
} 
timeString = theday+xfile+hours+minutes+seconds; 
Clock.innerHTML = timeString; 
window.setTimeout("tick();", 100); 
} 
window.onload = tick; 
</script> 
</head> 
<body> 
<div id="Clock" align="center" style="font-size: 12px; color:#000000"></div> 
</body> 
</html> 这个必须是前端调服务端时间
只能每隔一个时间段刷新获到数据
http不能实现真正serverpush 累死你 

上一个:asp中 右下角出来个方框 提醒功能怎么做? 比方说:QQ 右下角出现 消息提示 按×关闭 网页中也有这项功能
下一个:ASP.NET中我想在网站的页面上实现广告跟随滚动条而移动的效果 我的代码如下 求高手指点

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,