asp.net页面中Timer控件失效不起作用,谢谢大家
页面在原先的项目里运行正常,现在把页面复制到新的项目中就失效了,不知道为什么?另外web.confige需要配置吗页面:<%@Registerassembly="Syst...
页面在原先的项目里运行正常,现在把页面复制到新的项目中就失效了,不知道为什么?另外web.confige需要配置吗
页面:
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer runat="server" OnTick="Timer1_Tick" Interval="1000" >
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
后台:(方法里面的代码运行正常我单独摘出来验证了)
protected void Timer1_Tick(object sender, EventArgs e)
{
lbl.Text = DateTime.Now.ToLongTimeString();
int result = 0;
//int ddid = 0;
string jis = "select jishi from kj where id= 1 ";
DataTable dt = code.GetTable(jis);
string jj = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["jishi"].ToString() != null)
{
jj = dt.Rows[i]["jishi"].ToString();
result = int.Parse(jj);
}
}
string Sql;
Sql = "Update kj_xueyuan set jishi=" + (result + 1) + " where id = 1 ";
code.UpDate(Sql);
} 展开
页面:
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer runat="server" OnTick="Timer1_Tick" Interval="1000" >
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
后台:(方法里面的代码运行正常我单独摘出来验证了)
protected void Timer1_Tick(object sender, EventArgs e)
{
lbl.Text = DateTime.Now.ToLongTimeString();
int result = 0;
//int ddid = 0;
string jis = "select jishi from kj where id= 1 ";
DataTable dt = code.GetTable(jis);
string jj = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["jishi"].ToString() != null)
{
jj = dt.Rows[i]["jishi"].ToString();
result = int.Parse(jj);
}
}
string Sql;
Sql = "Update kj_xueyuan set jishi=" + (result + 1) + " where id = 1 ";
code.UpDate(Sql);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询