您能否推薦一種方法在ASP.NET頁面上放置臨時定時器?ASP.NET頁面上的倒數計時器
現在我用這個代碼:
Default.aspx的
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server">60</asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000"
ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
Default.aspx.cs
protected void Timer1_Tick(object sender, EventArgs e)
{
int seconds = int.Parse(Label1.Text);
if (seconds > 0)
Label1.Text = (seconds - 1).ToString();
else
Timer1.Enabled = false;
}
但它是昂貴的流量。我寧願純粹的客戶端方法。在ASP.NET中可能嗎?
這很有趣,你問這個...我只是實現類似你們的解決方案前幾天。它必須完成,這是快速和骯髒的。我會很樂意看到如何做到這一點客戶端。 – mattruma 2008-09-20 19:26:52