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

x
  • 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
        Stop
        Ds_SLAApp1.tbl_Cases.Clear()
        dta_Cases.Fill(Ds_SLAApp1)
        grd_Cases.DataSource = Ds_SLAApp1.tbl_Cases
        grd_Cases.DataBind()
        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?
0
SADiver
Asked:
SADiver
1 Solution
 
Michel SakrCommented:
it should be a client side script, try to refresh thru a meta tag...
code in 10 seconds
0
 
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
0
 
naveenkohliCommented:
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..
HEAD>
<TITLE>Auto Refresh Page Example</TITLE>
<META HTTP-EQUIV="Refresh" CONTENT="60">
</HEAD>


0
 [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
0
 
Michel SakrCommented:
:o) Speed counts...
0
 
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!
0
 
Ghis68Commented:
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

thanks
0

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