在ASP.NET中使用计时器控件 [英] Use of timer control in ASP.NET
本文介绍了在ASP.NET中使用计时器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
--------------------------USE OF TIMER CONTROL IN ASP.NET(VB)---------------------------------------------------
<table runat ="server" style="width: 818px" >
<tr>
<td>
</td>
<td>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1000">
</asp:Timer>
</div>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="UpdatePanel1 not refreshed yet."></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="UpdatePanel2 not refreshed yet."></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = "UpdatePanel1 refreshed at: " & _
DateTime.Now.ToLongTimeString()
'Label2.Text = "UpdatePanel2 refreshed at: " & _
' DateTime.Now.ToLongTimeString()
Dim tickCount As Integer = 0
If ViewState("TickCount") IsNot Nothing Then
tickCount = CType(ViewState("TickCount"), Integer)
End If
tickCount += 1
ViewState("TickCount") = tickCount ' Decide whether to disable the timer.
If tickCount > 120 Then
Label1.Text = "Time is Over!!!!!!!"
Timer1.Enabled = False
End If
End Sub
推荐答案
Google揭示了所有内容:
http://msdn.microsoft.com/en-us/library/bb386404.aspx [ ^ ]
[ ^ ]
Google reveals all:
http://msdn.microsoft.com/en-us/library/bb386404.aspx[^]
646,000 results for "using timers in asp.net" [^]
您正在尝试仅提及Code,并且仅此而已.这是你的问题吗?您刚刚提出了另一个问题有 [ ^ ],方法相同,没有任何区别具体细节.
如果您有任何疑问,请提及它,否则仅发布代码将无济于事.
You are trying to mentioned only Code and have not mentioned anything more. is it your question? you''ve just posetd another question there[^] in same manner without any specific details.
if you have any query so please mention it otherwise posting only code will not help you.
这篇关于在ASP.NET中使用计时器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文