0

i have same problem as this question.se the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation i havent any problem with <%@ Page EnableEventValidation="false" %>.I solve it and i try

protected void Timer1_Tick(object sender, EventArgs e)
{
        Label2.Text = Convert.ToString((Convert.ToInt32(Label2.Text) - 1));
        if (Convert.ToInt32(Label2.Text) == 0)
        {

            Timer1.Dispose();
            Submit();
        }
}

Code work fine means submit () is work if i call from submit button.If its call from Timer_Tick its not work.And timer is not stop or dispose.What is a problem plz suggest?

timer:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
                                </asp:Timer>
                                <asp:Label ID="Label1" runat="server" Text="Remaining Time:(Min)"></asp:Label>
                                <asp:Label ID="Label2" runat="server" Text="100"></asp:Label>
                            </ContentTemplate>
                        </asp:UpdatePanel>
Community
  • 1
  • 1
4b0
  • 21,981
  • 30
  • 95
  • 142
  • can you show your code where you initialize your timer? I suspect you've got something not quite right there. Are any exceptions thrown? Does it ever fire the Timer_Tick method? – Anthony Shaw Jan 05 '12 at 17:04
  • also where in the code is Timer1 declared what is it's access level.. – MethodMan Jan 05 '12 at 17:05

2 Answers2

0
Label2.Text = Convert.ToString((Convert.ToInt32(Label2.Text) - 1));

Does that line works?

Maybe the if

Convert.ToInt32(Label2.Text) == 0

doesn't return true

Raymen
  • 1
0

where are you Enabling or Starting the timer on the page? The timer will not automatically start upon page load, you will need to explicitly call Start() or set Enabled = true

Anthony Shaw
  • 8,146
  • 4
  • 44
  • 62