views:

359

answers:

3

Hi everyone!

I have this situation: I have a page where I have a list of events of a day. And these events can be changed theirs status to 'Confirmed' or 'Cancelled'.

But, when I, for instance, click on 'Confirmed', this status is saved on SQL Server and this status is shown 'Confirmed'. But, if another person has this same page opened at the time I changed the event status, this person WILL NOT see the new status. He only will see if reloads the page.

I know that there is a Ajax set TimeOut that refreshes page after every 5... 10... 15 seconds. But I was thinking if there's a jQuery or ASP.NET MVC trigger that when I change the event status, the server responds with a browser refresh.

Is there any solution for that??

Thanks!!

+1  A: 

Option 1: Use jQuery Timer and update your control on page every X seconds. (You don't have to reload the whole page, just states of your controls with confirmed/cancelled statuses, and change them only if server has returned new values).

Option 2: You can tigger an event on page from your server by using Silverlight 2+.

Hint: When you update control's state (confirmed/cancelled) pass initial state as well. Thus if one user has updated status from confirmed to cancelled, another user who will try update this status from confirm to cancelled will recieve a friendly error message.

Koistya Navin
Neither options is suitable for me... :-( What I need is to refresh some other page when I change an event status.
AndreMiranda
option 1 would work then...
Nathan Koop
Then you should put the timer on this "other" page.
Darin Dimitrov
@AndreMiranda, listen to what darin tells :-) There are no other options.
Koistya Navin
A: 

In short: no.

The server does not remember where it sent pages to. Once the server sends a page to the browser, it ends the connection. Due to this, the server would have no idea where to send refresh instructions or a new page. To do "real time" updates on a web page, the browser needs to initiate the call.

Jeremy B.
A: 

You can use asynchronous handlers in ASP .NET to implement that. Which means, you can subscribe to an update event on the server, and the server holds the request (which does not consume any worker threads in the meantime), and when the status is updated the request is ended and the response with the new status is sent to the client.