Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net System.Timers.Timer在If语句中不工作_Asp.net_Timer_Webforms - Fatal编程技术网

Asp.net System.Timers.Timer在If语句中不工作

Asp.net System.Timers.Timer在If语句中不工作,asp.net,timer,webforms,Asp.net,Timer,Webforms,我正在asp.net项目中使用计时器。我想在一天中的特定时间运行函数。但是计时器在我的if语句中不起作用。我先用msgbox测试它,但它没有开火 这是我的密码: Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Label5.Text = DateTime.Now.ToString("hh:mm:ss") If Label5.Text = "1:23:00" Then

我正在asp.net项目中使用计时器。我想在一天中的特定时间运行函数。但是计时器在我的if语句中不起作用。我先用msgbox测试它,但它没有开火

这是我的密码:

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

    Label5.Text = DateTime.Now.ToString("hh:mm:ss")

    If Label5.Text = "1:23:00" Then
        Timer1.Enabled = False
        MsgBox("Timer")
    End If
End Sub

我不知道它将如何工作。有人对此有想法吗?提前谢谢

尝试将
“hh:mm:ss”
更改为
“h:mm:ss”
hh
将给出01,
h
将给出1。参考或者,您可以更新
if
语句以与
01:23:00
进行比较。您必须在页面中添加一个ScriptManager标记才能使用计时器组件-您是否将其与ScriptManager/UpdatePanel一起使用?