JS定时刷新该页面不就得了
window.setInterval("refreshFrom();",180000)
function refreshFrom()
{
location.href=location.href+"&"+new Date();
}
window.setInterval("refreshFrom();",180000)
function refreshFrom()
{
location.href=location.href+"&"+new Date();
}
调试欢乐多
{
InsertData();
setTimeout("fasf()",100000)
}function InsertData()
{
var httpxml = new ActiveXObject("Microsoft.XMLHTTP");
httpxml.open("post","RevertMessage.aspx",false);
httpxml.send(null);
if(httpxml.status==200)
{
.................
}
}
别定时刷新..用ajax异步访问
参看我发给你的代码..
你在页面实现 ICallbackEventHandler 接口,就可以实现你的目的了
<%@ Page Language="C#" AutoEventWireup="true" Debug="true" CodeFile="Index.aspx.cs" Inherits="Index" %>
<!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>
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<div>
<asp:TextBox ID="TestTxt" runat="server"></asp:TextBox>
<br />
<br />
<input onclick="CallTheServer(TestTxt.value)" type="button" value="提交" />
<br />
<br /> </div>
</form>
</body>
</html>
后台代码:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; public partial class Index : System.Web.UI.Page, ICallbackEventHandler
{
string returnValue;
protected void Page_Load(object sender, EventArgs e)
{
string ReceiveScript = @"
function ReceiveServerData(arg)
{
alert(arg);
}";
ClientScript.RegisterClientScriptBlock(this.GetType(), "ReceiveServerData", ReceiveScript, true);
string CallbackScript = @"
function CallTheServer(arg) {
" + ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", null) + @";
}
";
ClientScript.RegisterClientScriptBlock(this.GetType(), "CallTheServer", CallbackScript, true);
}
// 接收客户端消息 eventArgument就是客户端传递过来的那个arg
public void RaiseCallbackEvent(string eventArgument)
{
//这里执行数据库操作;
returnValue = "ok"
}
// 返回客户端
public string GetCallbackResult()
{
return returnValue;
}
}