Friends, all of you are familiar with the Global.asax file in ASP.Net; if you don't then first read this about Global.asax:
discuss the various events in Global.asax file.
Global Application Class [Global.asax]
Application state only achieved by adding Global.asax file into our project; it is not mandatory to define a Global.asax file web project and if you have not added a Global.asax file then the ASP.NET Runtime detects that there was no Application State mangement in the current project.
Events in Global.asax File
Some of the Events in the Global.asax file are depicted as follows; this is not a complete list of events.
Application_Start: This event fires executes when the application starts running
Application_End: This event ocurs on application shutdown
Application_Error: This event ocurs when unhandled error occurs
Session_Start: This event ocurs when new session is started.
Session_End: This event occurs when session ends
So now we see the steps for the chat application:
Step 1) Open Visual Studio 2008/10
Step 2)Add wweb two web form Default.aspx and Chating.aspx ok
Step 3) Now Right click on the project and Add New Item; in that select the Global.asax file and in it write the following:
{
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application.Lock();
Application["msg"]="";
Application.UnLock();
}
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 mod
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
}
Step 4) Now go to the Default.aspx page source code and write as following:
{
<form id="form1" runat="server">
<script language="jscript" type="text/javascript">
function popup()
{
var a=window.open("chating.aspx",'width=250,height=500,left=350,top=120')
}
</script>
<body onload="popup(); return false;">
}
Step 5) Now design the Chating.aspx page along with three textboxes and one button.
Step 6) Now go to the Chating.aspx page_load event and wrte code as follows:
{
//Assigning Application Object to string Varaiable by Parsing
string msg = (string)Application["msg"];
TextBox1.Text = msg;
}
Step 7) Now go to the Chating.aspx button's double-click event and write code as follows:
{
string name = TextBox2.Text;
string message = TextBox3.Text;
string my = name + "::" + message;
Application["msg"] = Application["msg"] + my + Environment.NewLine;
TextBox1.Text = Application["msg"].ToString();
TextBox3.Text = "";
}
Step 8) Now run the application in two browsers and verify that the Chat works.

Aditya MahajanPosted Jan 9, 2019, 7:36 AM
Great small and simple
sandeep palPosted May 28, 2018, 10:31 PM
How to develop customer support chat in aap.net website plz help
Shweta GawkarPosted May 27, 2015, 9:28 AM
Thank you
Sachin JainPosted May 18, 2014, 5:00 AM
is link ko refer karo
Sachin JainPosted May 18, 2014, 5:00 AM
http://www.chatjs.net/
ketan italiyaPosted Sep 10, 2013, 1:20 AM
nice work thanks.
Guest UserPosted Mar 20, 2013, 10:41 AM
visit this its awesome chat control and its free http://programmingwithhardcoderz.blogspot.in/2013/03/facebookgmail-style-aspnet-jquery-ajax.html
Ashutosh AlexandarPosted Jan 23, 2013, 7:02 AM
did the problem of getting message after reloading the page again got solved?plz dont use the auto refreshing of page technique
Manish MishraPosted Dec 28, 2012, 5:42 AM
hi.. this application is not working on two different browsers... if i debug this in two different browsers, it only shows the chat history and not the messages passing from one instance to another. pleaes send all the details about this simple app asap.
amitendra singhPosted Nov 16, 2012, 5:57 AM
thank u
amitendra singhPosted Nov 16, 2012, 5:57 AM
thank u
yousif yousifPosted Oct 17, 2012, 4:35 AM
i need to do chat in my website am using eCommerce web application
amir imameditedPosted Sep 28, 2012, 3:28 AMEdited Sep 28, 2012, 3:29 AM
It's very good simple application .. but it needs to reload the page to show what the other user wrote. can u please solve this problem ?
piklu guhaPosted Apr 18, 2012, 3:22 AM
where is the chatting.aspx file in the zip package?????
Shalini JunejaPosted Apr 14, 2011, 7:45 AM
helpful article
Suthish NairPosted Apr 13, 2011, 3:16 AM
Dinkar, I opened the pages in VS2010. Lots of error poping up. 1. The ID 'form1' is already used by another control. 2. Element 'Body' cannot be nested within Form block. Can you check the pages with VS2010, its not working..
Dinesh BeniwalPosted Apr 13, 2011, 1:42 AM
Useful Article....
Vahaj uddinPosted Apr 12, 2011, 11:50 AM
2 Big Thumbs Up :) !!!!!