开发者

AJAX Timer I Cannot Disable My Button, When Variable Seconds Becomes 0

开发者 https://www.devze.com 2023-03-23 06:04 出处:网络
I have an Ajax timer, where I have the following code !!!strong text protected void Timer1_Tick(object sender, EventArgs e)

I have an Ajax timer, where I have the following code !!!strong text

   protected void Timer1_Tick(object sender, EventArgs e)
    {

        TimeSpan time2 = new TimeSpan();
        time2 = (DateTime)Session["Qtime"] - DateTime.Now;
        if (time2.Seconds <= 10 && time2.Minutes == 0)
        {
            ***if (time2.Seconds <= 0)
            {

                btn_submit.Enabled = false;
                lbl_next.Text = "Please Go for next question!!";


            }***
            else
            {
                lbl_qstntime.Text = "[ " + time2.Seconds + " S ]";
                lbl_qstntime.BackColor = Color.Red;开发者_如何学Go

                //lbl_qstntimedesc.BackColor = Color.Red;
            }

        }
        else
        {
            lbl_qstntime.Text = "[ " + time2.Seconds + " S ]";
        }
    }

The problem is when the seconds == 0 I am trying to disable one button, that is btn_submit.Enabled = false; lbl_next.Text = "Please Go for next question!!";

However that is not working Till I click any button (Including My submit button) in the page...

Can anyone tell me how can I achieve it, everything else is working just great :(

Requirement : "When variable seconds become 0 or l disable my Button ". Currently until I did not click any button it is not happening.

Thanks, Jithu


As @YuriyRozhovetskiy told I did not put the btn_submit inside the Update Panel. After putting the button inside update panel everything worked pretty well.

0

精彩评论

暂无评论...
验证码 换一张
取 消