Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

data not refreshing on timer event

I have an ASP.NET (VB.NET) project with a Webform that contains a connection to a database and a grid displaying the results of a query. I want to refresh the displayed results every 10 minutes.

So I used a Timer control with the following event handler:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmr_Refresh.Elapsed
        'refresh data
        grd_Cases.DataSource = Ds_SLAApp1.tbl_Cases
        Label1.Text = "done"
End Sub

I set the properties of the timer to the following:
interval=10000 '10 seconds
Autoreset=false 'trigger once only

I inserted the stop so that I can see if the event actually fires, then I trace through the rest of the sub.

The problem is that as soon as the ".Fill" method is called, the sub is terminated (like an "Exit Sub") and non of the rest of the instructions are executed!

At this stage I am guessing that the timer event is not server-side, and does not cause a postback to the server (something that I would probably need for my code to work).

How can I get the event to execute correctly, or get it to do a postback to the server, so that I can do the refresh of the data on the page_load event or something like that?
1 Solution
Michel SakrCommented:
it should be a client side script, try to refresh thru a meta tag...
code in 10 seconds
Michel SakrCommented:
add this in the html part of your aspx document.. in the header:

<META HTTP-EQUIV=Refresh CONTENT="10; URL=yourpage.aspx">
tells the browser to load yourpage.aspx 10 seconds after the current document has finished loading
The server side timer is not the way to go. It is not going to refresh the client browser. ASP.Net is a server side technology. To accomplish this,

1. Add REFRESH meta tag at top of your page..
<TITLE>Auto Refresh Page Example</TITLE>

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Michel SakrCommented:
well 10 minutes will be a value of 600
Michel SakrCommented:
:o) Speed counts...
SADiverAuthor Commented:
Excellent, this resolved the problem!

Now, Could I ask that if someone knows why the origenal method doesn't work, that you please post that here as well?

There must be a reason for putting the Timer control in ASP.NET. What is it's function and how are you supposed to use it?

"Silvers5", Thanks a mil for the help!
I am trying to do the samething has you.  I only want to refresh the data portion of the WEB page so the page is not reload and does not flash. The Meta is working like they mention but it need to be a way to do exactly what you want.  If you have found it please let me know.

I know what I am writting will not help but it will allow me to trace your question so if I found the answer I let you know


Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now