{
System.Timers.Timer t = new System.Timers.Timer(120000);
t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_TimesUp);
t.Enabled = true;
}
private void Timer_TimesUp(object sender, System.Timers.ElapsedEventArgs e)
{
//button1.PerformClick();
btnSearch.Click += new EventHandler(btnSearch_Click);
btnSearch_Click(null, null);
}
public DataTable gcs()
{
DataTable mydt = bll.jsbx();
return mydt;
}
protected void btnSearch_Click(object sender, EventArgs e)
{
DataTable mdt=gcs();
if(mdt.Rows.Count>0)
{
Application.Lock();
Application[“wx”] = 1;
Application.UnLock();
//System.Web.HttpContext.Current.Response.Write(“<script>init()</script>”);
System.Web.HttpContext.Current.Response.Write(“<script type=”text/javascript”>window.parent.location.href=”../main.aspx”;</script>”);
//System.Web.HttpContext.Current.Response.Write(“<script language=”javascript” defer>top.leftFrame.location.href=”main.aspx”</script>”);
gvClass.DataSource = mdt;
gvClass.DataBind();
}
}
直接点击button可以刷新页面,但是两分钟刷新提示System.Web.HttpContext.Current.Response.Write(“<script type=”text/javascript”>window.parent.location.href=”../main.aspx”;</script>”);未将对象引用设置到对象的实例?
40
System.Timers.Timer t=null;
protected void Page_Load(object sender, EventArgs e)
{
t = new System.Timers.Timer(120000);
t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_TimesUp);
t.Enabled = true;
System.Threading.Thread.Sleep(5000);
}
private void Timer_TimesUp(object sender, System.Timers.ElapsedEventArgs e)
{
//button1.PerformClick();
btnSearch.Click += new EventHandler(btnSearch_Click);
btnSearch_Click(null, null);
t.Enabled=false;
}
public DataTable gcs()
{
DataTable mydt = bll.jsbx();
return mydt;
}
protected void btnSearch_Click(object sender, EventArgs e)
{
DataTable mdt=gcs();
if(mdt.Rows.Count>0)
{
Application.Lock();
Application[“wx”] = 1;
Application.UnLock();
//System.Web.HttpContext.Current.Response.Write(“<script>init()</script>”);
System.Web.HttpContext.Current.Response.Write(“<script type=”text/javascript”>window.parent.location.href=”../main.aspx”;</script>”);
//System.Web.HttpContext.Current.Response.Write(“<script language=”javascript” defer>top.leftFrame.location.href=”main.aspx”</script>”);
gvClass.DataSource = mdt;
gvClass.DataBind();
}
}