private int index
{
get
{
object o = ViewState["index"];
return (o == null) ? 0 : (int)o;//设定起始时间
}
set
{
ViewState["index"] = value;
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
if (this.index >= 100)
this.Timer1.Enabled = false;
else
{
this.index++;
this.lbTime.Text = this.index / 60 + "分" + this.index % 60 + "秒";
}
}
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="100" ontick="Timer1_Tick">
</asp:Timer>
<asp:Label ID="lbTime" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>