Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6220917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:02:35+00:00 2026-05-24T08:02:35+00:00

In my form there there is a Submit Button and another Timer… Submit button

  • 0

In my form there there is a “Submit Button” and another Timer… Submit button submits a request that may take few minutes to serve..Mean while the timer would poll at short intervals (say 5 secs ) and keep the user updated.. But the issue is that timer stops polling as soon as the Submit button is clicked.. I am attaching the working sample code of the application..Does anyone know why this is happening..Thanks in advance.

<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div>
                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Submit_Click" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger  ControlID="Timer1" EventName="Tick" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:Timer ID="Timer1" Interval="700" runat="server" OnTick="UpdateTimer_Tick">
    </asp:Timer>
    </form>
</body>

Code Behind

  protected void UpdateTimer_Tick(object sender, EventArgs e)
        {
            Debug.Write("Timer");
            Label1.Text = DateTime.Now.ToString();
        }

        protected void Submit_Click(object sender, EventArgs e)
        {
            Debug.Write("Submit Start ");
            for (int i = 0; i < 1000; i++)
            {
                Thread.Sleep(100);
            }
            Debug.Write("Submit  End   ");
        } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:02:36+00:00Added an answer on May 24, 2026 at 8:02 am

    I think the timer is stopped on postback (button-click) and will only start again when that postback returns. One solution to this is to use PageMethods instead of the timer, but you can only make static functions a PageMethod. For the example it would work like this:

    [WebMethod()] public static string GetTime(){
        Return DateTime.Now.ToString();
    }
    

    html and javascript (jquery):

    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div>
                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Submit_Click" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    
    <script type="text/javascript">
        function OnSuccess(result, ctrl) { $('#<%=Label1.ClientID %>').html(result); }
        function OnError() { alert("error!"); }
        $(document).ready(function() {
            setInterval(function() { PageMethods.GetTime(OnSuccess, OnError); }, 700)
        });
    </script>
    
    </form>
    </body>
    

    Don’t forget to set EnablePageMethods=”true” when using webmethods!

    While testing this I noticed the response was slower than the SetTimeout triggering a new ajax call, so the page rapidly builds up running connections, this might be because my development server is a bit slow. To fix this you should not update so frequently, once every 5 seconds will have to do.

    I guess the asp.net timer already prevents this behavior: it stops when another ajax call is done. This behavior causes the problem you’re experiencing, the button postback blocks the timer updates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way I can tell how many times a form submit button
In my form there is a textbox and submit button. When a user starts
I have some code that uses a form.submit() to open up another window when
I have a form inside a dialog that appears after clicking in another button.
Need the three Options to be hyperlinks that submit the choice form. When submitted,
I need a Timer in a 'no form' Delphi unit (there's still a main
Is there any html form class(text box) that does not allow null values. The
I'm trying to submit a form without a submit button. This form takes values
Let's assume I have a very simple form, with a submit button and a
I have a form within another form: <form id=a> <form id=b> <input type=submit> When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.