This is a simple chat room no data base place it in a admin folder it comes from the book ASP.Net Step by Step I have a couple of them on my sites the work fine for what I need them for
hope this helps don't forget to mark as answer
Put this is a aspx page
<asp:Timer ID="Timer1" runat="server" Interval="15000">
</asp:Timer>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<h1>Welcome to bed bug chat</h1>
<h3>
Group Chatting...Tell others what worked for you. There is nothing to install just
enter your name</h3>
<asp:Label ID="Label2" runat="server" CssClass="M " Text="Enter your name for chat session: "></asp:Label>
<asp:TextBox ID="TextBoxUserID" runat="server" Width="244px" TextMode="SingleLine"></asp:TextBox>
<asp:Button ID="ButtonSubmitID" runat="server" OnClick="ButtonSubmitID_Click" Text="Submit ID"
Width="101px" />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBoxConversation" runat="server" Height="156px" ReadOnly="True"
TextMode="MultiLine" Width="748px" CssClass="textbox" Wrap="True" BackColor="#CCFFFF"
BorderColor="#9933FF" BorderStyle="Groove" BorderWidth="40px" ForeColor="Black"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Label ID="Label1" runat="server" CssClass="M" Text="Type your message here: Double click in the test box to view your input"></asp:Label>
<br />
<asp:TextBox ID="TextBoxMessage" runat="server" Width="750px"></asp:TextBox>
<br />
<asp:Button ID="ButtonAddYourMessage" runat="server"
Text="Add Your Message" BorderWidth="8px" BorderStyle="Groove" BorderColor="#FF66FF"
BackColor="#FF0066" ForeColor="Black" Width="200px" Font-Underline="True" Font-Bold="True"
Font-Size="Large" Font-Italic="True" OnClick="ButtonAddYourMessage_Click"/>
<asp:Button ID="Button1" runat="server" Text="Home" BorderWidth="8px" BorderStyle="Groove"
BorderColor="#FF66FF" BackColor="#FF0066" ForeColor="Black" PostBackUrl="Default.aspx"
Width="200px" Font-Underline="True" Font-Bold="True" Font-Size="Large" Font-Italic="True" />
Put this in your code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
TextBoxConversation.Text = "Welcom to barterlinks";
ManageUI();
RefreshConversation();
}
void ManageUI()
{
if (GetUserID() == null)
{
// if this is the first request, then get the user's ID
TextBoxMessage.Enabled = false;
TextBoxConversation.Enabled = false;
ButtonAddYourMessage.Enabled = false;
ButtonSubmitID.Enabled = true;
TextBoxUserID.Enabled = true;
}
else
{
// if this is the first request, then get the user's ID
TextBoxMessage.Enabled = true;
TextBoxConversation.Enabled = true;
ButtonAddYourMessage.Enabled = true;
ButtonSubmitID.Enabled = false;
TextBoxUserID.Enabled = false;
}
}
void RefreshConversation()
{
List<string> messages = (List<string>)Cache["Messages"];
if (messages != null)
{
string strConversation = "";
int nMessages = messages.Count;
for (int i = nMessages - 1; i >= 0; i--)
{
string s;
s = messages[i];
strConversation += s;
strConversation += "\r\n";
}
TextBoxConversation.Text =
strConversation;
}
}
protected void ButtonAddYourMessage_Click(object sender, EventArgs e)
{
// Add the message to the conversation...
if (this.TextBoxMessage.Text.Length > 0)
{
List<string> messages = (List<string>)Cache["Messages"];
if (messages != null)
{
this.TextBoxConversation.Text = "";
string strUserID = GetUserID();
if (strUserID != null)
{
messages.Add(strUserID +
": " +
TextBoxMessage.Text);
RefreshConversation();
TextBoxMessage.Text = "";
}
}
}
}
protected void ButtonSubmitID_Click(object sender, EventArgs e)
{
Session["UserID"] =
TextBoxUserID.Text;
ManageUI();
}
protected string GetUserID()
{
string strUserID =
(string)this.Session["UserID"];
return strUserID;
}
add a Global.asax remove every thing and place this in it
<%@ Application Language="C#" %>
<%@ Import Namespace ="System.Collections.Generic" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
List<string> messages = new List<string>();
HttpContext.Current.Cache["Messages"] = messages;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>