<asp:Timer runat="server" id="UpdateTimer" interval="1000" ontick="UpdateTimer_Tick" />
<asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" CssClass="h4" id="DateStampLabel" />
</ContentTemplate>
</asp:UpdatePanel>
Back End-Code
Private Sub btnStartTimer_Click(sender As Object, e As EventArgs) Handles btnStartTimer.Click
UpdateTimer.Enabled = True
If txtStartTime.Text.Length = 0 Then
txtStartTime.Text = Now.ToLongTimeString
End If
'ViewState("Timer") = "Start"
'ViewState("StartTime") = Now.ToLongTimeString
If ViewState("Time") Is Nothing Then
Dim time As DateTime = New DateTime(2015, 1, 1, 0, 0, 0).ToString("H:mm:ss")
ViewState("Time") = time
End If
btnStartTimer.Enabled = False
btnPauseTimer.Enabled = True
btnEndTimer.Enabled = True
End Sub
Public Sub UpdateTimer_Tick(sender As Object, e As EventArgs) Handles UpdateTimer.Tick
Dim dt As DateTime
dt = CType(ViewState("Time"), DateTime)
dt = dt.AddSeconds(1)
ViewState("Time") = dt
DateStampLabel.Text = dt.ToString("H:mm:ss")
End sub
好的我的计时器运行顺畅,即启动,停止,暂停,恢复本地主机,但是当我上传服务器时,计时器没有运行...为什么?请帮助我:(
注意:我使用计时器作为秒表。请记住它在本地主机上运行
答案 0 :(得分:0)
只需向ToolScriptManager添加属性即可 CombineScript = “假”