My scenario:
After client login, my user will be redirected to the index.aspx page. Inside this page I will put one div with a gridview inside. This gridview will be showing data from one table.
My question is: How to refresh this gridview always that one record is saved on this table?
Ps.: I´ve seen a lot of examples using "server push" tecnology, comet, ajax, etc. Don´t know the best way to do that and can´t find a really simple example.
When a new record is added to the table, the real challenge is communicating those changes to the client in real-time without polling in intervals or requiring some sort of user interaction.
You have a couple of options:
Your best bet is to use a WebSocket, which enables bidirectional communication between the client and server. This is the solution I would pick.
Here are some examples using WebSockets:
There are a few good libraries around too that will take care of most of the leg work. A couple to check out are WebSync and PokeIn. Both products offer decent documentation and community editions that you can download for free.
Here are some tutorials to check out:
Use AJAX to poll for changes every X number of seconds. If changes are detected reload the page, otherwise do nothing.
You can use setinterval javascript method. I act as a timer and use submit form to refresh the page. other method could be asp.net ajax toolkit timer control here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With