Click here to Skip to main content
15,885,767 members
Articles / Web Development / ASP.NET

Multi User Chat Room Using ASP.NET 2.0 and AJAX

Rate me:
Please Sign up or sign in to vote.
4.82/5 (43 votes)
28 Feb 20074 min read 432.4K   16.1K   162  
Describes how you can build a multi user chat room using ASP.NET 2.0 and AJAX extensions
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Login to The Chat Room</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
        
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
      	<table>
				<asp:Panel Runat="server" ID="pnlLogin">

						<tr>
							<td>User Name :</td>
							<td>
								<asp:TextBox id="txtUserName" Runat="server"></asp:TextBox>
								<asp:RequiredFieldValidator id="req1" Runat="server" Display="Dynamic" ErrorMessage="8" ControlToValidate="txtUserName"></asp:RequiredFieldValidator></td>
						</tr>
						<tr>
							<td colspan="2">
								<asp:Button cssclass="btn" id="btnLogin" Runat="server" Text="LOGIN" OnClick="btnLogin_Click"></asp:Button></td>
						</tr>
				</asp:Panel>
				<asp:Panel Runat="server" ID="pnlChat">
					<tr valign="top">
						<td valign="top">Choose Room:
						</td>
						<td>
							<asp:ListBox id="lstRooms" runat="server">
								<asp:ListItem Value="1" Selected="True">Sports</asp:ListItem>
								<asp:ListItem Value="2">Music</asp:ListItem>
								<asp:ListItem Value="3">Software</asp:ListItem>
							</asp:ListBox></td>
					</tr>
					<tr>
						<td colspan="2">
							<asp:Button CssClass="btn" id="btnChat" OnClick="btnChat_Click" Runat="server" Text="Join"></asp:Button></td>
					</tr>
				</asp:Panel>
			</table>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Egypt Egypt
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions