Timer Tick not increasing values on time interval

后端 未结 3 485
野的像风
野的像风 2020-12-10 16:52

I want to increase values on timer tick event but it is not increasing don\'t know what I am forgetting it is showing only 1.



        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 17:18

    Check whether the form is posted back and then assign values. Check IsPostBack

    private int i;
    
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            i = 0;
        }
        else
        {
            i = Int32.Parse(Label3.Text);
            i++;           
        }
    
        Label3.Text = i.ToString();
    }
    

提交回复
热议问题