How to access DB and allow FORM POST?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

Say I have a chat page. The bottom has a FORM text box with send button.
The middle and upper part of this page display the chat text. A user
submits their chat text and sees it displayed in the chat area. The text
goes into a database and then is output into the chat area. I need
something to check the database for new entries about every 2 seconds or so
and then display them in the chat area. I could use frames and hide the one
page that does the database INSERT and SELECT. Is there another way without
frames?

Also, is there a way to raise an event when a new message is inserted into
the database, rather than just polling it every few seconds?

Thanks,
Brett
 
I know of no path that will allow the server to raise an event on a client,
though it wold be nice to have.

One solution that will accomplish what you want is:
1. Start a timer in JS when the page loads.
2. When the timer fires, contact the server (possibly via a web service) to
see if anything new is in. If yes, postback to that control for a refresh,
otherwise restart the timer.
 
What about the event being raised on the server side and pushing to the
client. The use of a web service is interesting. However, if the server
pushes, the client still has to listen somehow, which gets back to a
constant page refresh or refresh with JS.
 
The webservice would be a good way of doing it. As mentioned earlier I
don't think there is any way of having the server fire events on the client.

But if you have a client side javascript fire regularly you can have it
access a web service to check for updates, without doing a refresh, using a
web behavior. You can find stuff on web behaviors here (including the
behavior.htc file) :
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/using.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top