4

I have a multiuser application, I need to refresh an Update panel when one of users change the state of an application variable to true.

What is the best way to do this?

I've tried with a timer, but on timer tick all page was postback.

Thanks

-------EDIT--------

Thanks for suggestions, I would try to explain better my problem.

I have a big database, shown in a bound gridview. Most users only read data, but someone can edit. Is very important that the changes appears immediately to all users that are seeing the GridView. The best solution that I found is to define an application variable and users that are editing set this variable to true. All other users update GridView only if the application variable is true, else they do nothing.

Is that a good solution?

What is the better way to update the GridView when the application variable change its state?

INDIA IT TECH
  • 1,902
  • 4
  • 12
  • 25
Pietro Z.
  • 521
  • 2
  • 6
  • 18
  • 2
    Without a concrete example of the problem, the best I can offer is: the update panel really should 'just work' unless your event-handling logic is colliding with your expectations. Webforms were intended to present complete forms that post-back to the server page-model events. The update panel's intent is to reduce the amount of http data between the client and server and eliminate the full-page refresh on the client. What might work better is js ajax calls to webservices. – Paul Jan 02 '16 at 16:31
  • 1
    Make sure the application variable changes are accessible by all sessions. Try making it a global variable. See this answer: http://stackoverflow.com/a/4174604/2549384 – Moon Jan 02 '16 at 19:17
  • @Don thanks for you suggestion, this help me to improve my application variable definition. – Pietro Z. Jan 03 '16 at 13:21
  • @Don My issue is a little bit different: I don't know how to Update the UpdatePanel that contain the gridview, when application variable change status. See my edit in the question, please... – Pietro Z. Jan 03 '16 at 13:26
  • Are you still looking for solution for this question? – INDIA IT TECH Mar 12 '16 at 12:16
  • I've found a workaround, if you have a good solution could you post? Thanks – Pietro Z. Mar 14 '16 at 21:40

1 Answers1

0

I would suggest a solution based on Paul's comment.

  • You put the GridView into an UpdatePanel and leave it there.
  • Then, "out of band", using some separate channel (a periodic ajax call or with the use of some special web api or in-browser messaging service) the client checks wheter to update.
  • When it's time to update, some javascript triggers an update of the UpdatePanel.

This way, you don't mess with the WebForms components, and have a light update checking mechanism.

Marcel
  • 15,039
  • 20
  • 92
  • 150