Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Timer Class 1

Status
Not open for further replies.

EnemyGateIsDown

Technical User
Oct 3, 2002
235
GB
Hi Guys,

I want to refresh some data on a page every X seconds and I have a sub which does this. Having done a bit of research it looks like I can do this with the timer class however I am having trouble implementing it.

Can someone tell me how I should use this class to call for example

sub Populate_data (Some Parameters)

every 10 seconds??

Any help is as always greatly appreciated.

Cheers,

Chris
 
It actually sounds like a Timer on the server won't do what you want (unless I've misunderstood). A timer on the server could easily be used to call the sub every x seconds, but if you are wanting to refresh a portion of the page with these results, it would seem that using an AJAX solution would be more appropiate (with a javascript timer triggering the call for data).

For an explanation on how ASP.NET has integrated AJAX, have a read up on Client Callbacks from here:


Also, here's some other good examples on how to implement them:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Hi ca8msm,

Its probably my explanation thats at fault :)

What I am trying to do is rebuild a table which is on the page every so many seconds to ensure that it shows the latest data but I don't want to re-post the page if possible.

I actually have a Server Submit button on the page which does exactly what I want without rebuilding the page but i want that to happen every X seconds.

Chris
 
What I am trying to do is rebuild a table which is on the page every so many seconds to ensure that it shows the latest data but I don't want to re-post the page if possible.
That actually sounds like a perfect case for an AJAX solution. If you use the button you have created, the whole page will be posted back when all you really want to do is update the data in the table.

If you go through some of the examples from above, it will give you a general idea on how AJAX works (i.e. you could create a button that only updated the table and didn't post the whole page back). Then, you can simply adapt your example to use a javascript timer to call the function, rather than the clicking of the button.

Set up a simple test harness to do this (i.e. like in the first of the four examples I posted, they use a ListDictionary rather than a database), and post back if you have any problems and we can go through it. That way, if you post the whole code here, it's not database driven and we can copy/paste your code to get a working example.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks as always c8msn, I'll have a look into AJAX and give you shout if i need any further help..

 
Just reading through the AJAX info it looks like its exactly what I need thanks c8msm, ill keep you posted .. and no doubt be harrassing you for help ;-)

Chris
 
OK, no probs [smile]


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top