Wednesday, March 21, 2012

use __doPostBack with Ajax

Hi,

I have a page that is updated frequentlly (it presents stock data) .

I use ajax contrl tool kit controls .

right now there is an ajax Timer control on the update panel, which calls the Update Panel's Update method if needed.

I get my data via wcf client proxy , my question is, is there a way to receive events from wcf on server side?

then hold an updated datatable of stock data?

Thanks

Take a look at this example ofusing __doPostBack to trigger an UpdatePanel refresh.

Additionally, you might be interested in this: http://encosia.com/2007/07/25/display-data-updates-in-real-time-with-ajax/


hello.

well, not sure on what you're asking here...if you want to have a partial refresh caused by your timer, then you should set it up as an asyncpostbacktrigger. if you only want to have a refresh when you receive new data on the server side, then you should do something like this:

1. build a web service that polls the server side to see if there is new data (you can, for instance, have a session variable that will let you know the date of the last update of the data on the server side)

2. when you receive the response you should see if you need to refresh the panel

3. if you do, you should use gt1329a's (sorry man, but i don't know your name :) ) excellent advise and force a refresh of your panel


Hi,

Thanks for your reply, I already implemented what you suggested (sorry for my confused question..)

but im looking for a more efficient solution, to reduce calls to wcf servic.(if its possible)

actually what I meant to ask is , is there a way to hold on server side a DataTable or any other data structure that

will be updated through wcf callbacks (or other type of callbacks from a DLL) , so when a client requests the page i don't need to call the wcf service.

I can bind my data presentation controls to the updated data structure , and server side will handle the updates regardless of client calls .

I think it will be more efficient then calling wcf services from the aspx pages for every request to that page and on each timer tick.

but where can I hold and update that data structure (via wcf callbacks) ?

i want it to be alive with no dependecy on page that are beeing requested.

what do you suggest?

Thanks,

tal


hello.

what you need is some sort of "asp.net singleton". adding a static field to the httpapplication object will be enough for that. here is an extremly interesting article about singletons:

http://www.yoda.arachsys.com/csharp/singleton.html

btw, do notice that this has some problems, specially when you think about web farms, etc...

No comments:

Post a Comment