Asp.net page "Timer"

Posted on 2011-10-27
Medium Priority
Last Modified: 2012-05-12
how can I implement a "timer" in asp.net 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
Luis Pérez earned 200 total points
ID: 37036742
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.

Accepted Solution

mr_nadger earned 1800 total points
ID: 37043613
you can do this quite easily with asp.net - I have a timer on an asp.net 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 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