Solved page "Timer"

Posted on 2011-10-27
Last Modified: 2012-05-12
how can I implement a "timer" in page, so i can call a function that lets save the data eg. 3 on 3 minutes.
Question by:rflorencio
    LVL 25

    Assisted Solution

    by:Luis Pérez
    You need to do that on the client side, because once the page has been sent to the client you don't have control over it anymore.

    In javascript, it's easy to set a timer:
    function recursive() {
        //do something
        //call again the function after 3 minutes
        window.setTimeout('recursive()', 3 * 60 * 1000); //3 minutes * 60 seconds * 1000 milliseconds

    Then, you can benefit from advanced technologies (like AJAX) or web services calls to do tasks on the server each time the client recursive() function is invoked.

    Hope that helps.
    LVL 7

    Accepted Solution

    you can do this quite easily with - I have a timer on an page, which triggers a datasource rebind; the datasource and the datagrid it populates are inside an update panel, with the update mode set to conditional.

    code snippets attached

    <asp:UpdatePanel ID="uppanServer" runat="server" UpdateMode="Conditional">
    	<ContentTemplate >
    		<asp:GridView ID="gvServerList" runat="server" CssClass="mGrid" 
    		AutoGenerateColumns="False" DataKeyNames="intid,serverName,cluster" 
    		DataSourceID="sqlServerList" Width="85%">
    <asp:Timer ID="tmrAutoUpdate" runat="server" Interval="300000"></asp:Timer>
    Protected Sub tmrAutoUpdate_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles tmrAutoUpdate.Tick
    End Sub

    Open in new window


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now