Automatically refreshing a textbox using .NET web services

K

Kevin Gibbons

Hi,

I have created a chat program using a web service to accept all text
input from a client and this then returns the submitted text to the
screen. The problem is at the moment the new message is only updated
when the page reloads (using a meta tag to automatically reload) but
it clears any previous messages.

Is there a way that I can automatically write any new messages to the
textbox, adding them to the current messages without reloading the
page?

tia

Kevin
 
D

DalePres

Check out the WebService behavior at
http://msdn.microsoft.com/workshop/author/webservice/overview.asp.

Another method is to use an iframe with an onload event handler to update
the control on the parent page.

There's a third method, but it's resource intensive and limits the number of
clients you can use. You can use an IHttpHandler to create your own custom
page generation, keeping the connection to the client open for the life of
the session, and just keep writing new messages to the client as the
messages come in. Create a HttpContext object and use the Response.Write()
and Response.Flush() methods to send new text to the clients. To know which
clients to send to, add the Session to an ArrayList in Session_Start and
check for null before writing, in case the session no longer exists. If the
session no longer exists, delete the session from the ArrayList.

Notice the suggestions get longer as they get more difficult. I'd suggest
starting with the WebService behavior.

DalePres
MCAD, MCSE, MCDBA
 
K

Kevin Gibbons

Thanks a lot for your help, I have used the Microsoft onresult
javascript example to retrieve the latest message at an interval of
every second. I am however still having a problem concatenating the
new message to the previous messages, at the moment only new messages
are being displayed and previous messages cannot be retrieved. Is
there any reason why this cannot be retreived?
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top