Basic Chat Using ASP .NET AJAX

Sign in to queue

The Discussion

  • User profile image

    How would you recommend handling that a user can't scroll up? This is due to the message list is updating every second. The javascript jumps to the bottom every second.

  • User profile image

    @Randy I would add in some javascript to check if a user scrolled up.  If they did then don't jump down

  • User profile image

    @Alton @jeksya working on getting the source and will move it to our server instead

  • User profile image

    @Alton @jeksya Personify Design gave me the source code and links have been updated.  Should work now.

  • User profile image

    hi, very nice example to get up and going, but it would be nice if you also updated the web.config

    I copied the web.config from a default 3.5 project and the whole thing compiled fine after that.

  • User profile image
    Dave Violette

    "@Randy I would add in some javascript to check if a user scrolled up.  If they did then don't jump down"

    Can someone help me with the code for this? I am not javascript expert.

    Also, any help in getting rid of flickering?

  • User profile image

    i am not able to download this link

  • User profile image

    @rahul Link at the top of the page labeld "Download" worked for me.

  • User profile image

    Can your chatters be added live or do they need to be preloaded as above in the global asax

  • User profile image

    I am a total noob on what to do after downloading the zip file. I hope someone can guide me how to test it. I tried opening the project in visual basic 2008 but there is no project file from the sample. I really have no idea what to do next. Smiley

  • User profile image

    @lost, Looks like you'll have to create a new project to run this.  sadly, looks like this example doesn't have a project file.

    I would follow the article and copy the code out of the files to recreate it.

  • User profile image
    Marvin d Martian

    has anyone tried extending the code to add login functions? Ive tried but the messages from other chatters won't show up.

  • User profile image

    Hey I'm using this basic code for a chat that I'm about to create but I cant figure out how and where to add a function that adds the users dynamically? Can anyone help me?

  • User profile image

    I am getting error at the chat.vb and chatter.vb saying the 'Type Chatter is not defined'

    Please can you help me in solving this problem?

    I have the same issue!

  • User profile image

    I deleted/exclude from project the web.config file and start debugging. This created the a new web.config file and fixed all the problems I had.


  • User profile image

    @pallavi what type of problem?

  • User profile image

    i am getting prob with chatter in glogal.asax.plz help me

  • User profile image


    The Code is working fine but how can this be activate for instant messaging between two users.

    Also how to pop up the message on the other users page,when i send him a message.

  • User profile image

    so could you help us on how to use the chat with logged in and logged out users in a session please? but only two people chatting to make it simple.....

  • User profile image

    Thanks for article and check for great ajax library with chat samples.

  • User profile image

    your code works gr8. but, what if user wants to scroll up to see previous conversation?

  • User profile image

    @davdav if you download the source code which is a link at the top of the article, you'll see the classes for those objects

  • User profile image

    chatter and chat is not defined..T_T

  • User profile image
    Bad BOy

    Is it just me, or is it now not working on final build of ASP.NET 2.0 Ajax Extensions 1.0?!

    Microsoft.Web.Extensions.dll missing?!@

    web config erro..How to Solve..

  • User profile image


  • User profile image
    Ravindar Kumar Gupta,​9650969114

    Thnaks for help

  • User profile image

    i had tried these but its showing some error, missing assembly or namespace for chat and chatter.

  • User profile image


  • User profile image


  • User profile image


  • User profile image

    Love the simplicity of the project, can you give me some tips on how to implement more than one chat room?

  • User profile image

    scroll bar is restrict to the bottom of DIV.
    how can we change the code so that scroll bar can go up while we scroll the scrollbar using mouse..?

  • User profile image
    abhinav bagora

    chatter and chat is not defined..
    how can i solve this problem?

  • User profile image

    Hi, really interested your Basic chat.
    I want to add new chatter.
    I simpelly add a textbox and a button, how can I added this new user into the chatter list.
    My code below make list become double.
    And after added new user I want this new user become current active user. How to do it Please?

    Protected Sub btnJoin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim chatters As List(Of Chatter) = New List(Of Chatter)
    chatters = CType(Application("Chatters"), List(Of Chatter))

    Dim id As Guid = Guid.NewGuid
    chatters.Add(New Chatter(id, txtNewUser.Text))

    m_chatter = Chatter.ActiveChatters(New Guid(id.ToString))

    For Each c As KeyValuePair(Of Guid, Chatter) In Chatter.ActiveChatters
    End Sub

  • User profile image

    But what if we can develop a chat that does not depend on session at all ? can I found one like that ?

  • User profile image


  • User profile image

    There's nothing worse than a tutorial with code that doesn't work.

  • User profile image
    Harish B K

    I just want to know hot to get Public Key Token which has mentioned in web.config file

    <validation validateIntegratedModeConfiguration="false"/>
    <add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler"/>

  • User profile image


  • User profile image


  • User profile image

    I've implemented a version of this on my own website. I use windows forms authentication, and set the page authentication to logged in users. However, Ithough users can log in and join the chat page, we all get redirected to the login page after just a few messages get posted.

    Is there something I should know about Ajax and forms authentication. I think the problem is because a partial post back fails authentication.

    I am developing the site for a hosted service so I can't debug live.

    Any suggestions?

  • User profile image



  • User profile image

    Hey this is really great but can you do an one with socket programming ?
    please reply asap

  • User profile image

    I'm getting error msg as index out of range at Chat.ActiveChats()[0].Any help to fix this issue?

  • User profile image
    suhas dakhare

    Please Help in developing the simple chat application in

  • User profile image

    I just want to thank you for that snippet of javascript that scrolls to the bottom of a window. I tried EVERY example given to do this on the web, and none of them worked.

    My no-frills web chat now works, is 35 lines of code in vb plus 2 update panels, 2 text boxes, and a button on the form. Easy peasy!

Add Your 2 Cents