Here we will learn how to create chat room for chatting in web application in asp.net with c# we can easily chat the application on our requirements.
Here design Default2.aspx page in asp.net .....
<div>
<table width="100%">
<tr>
<td width="15%">
<img src="121020111216.jpg" style="width: 167px; height: 105px" />
</td>
<td valign="top">
<span style="font-size:11pt; color:#003366; font-family:Trebuchet MS">
<strong>Pankaj
Chat
<br />
<br />
<img src="pr.png" style="width: 152px"/></strong>
</span>
</td>
</tr>
<tr>
<td colspan="3">
Show Message<span style=" font-size:10pt; color:#003333; font-family:Verdana"><strong>
</strong></span>
</td>
</tr>
<tr>
<td colspan="3">
<asp:TextBox ID="txtmsg" runat="server" Height="180px" TextMode="MultiLine"
Width="240px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
Name<span style="font-size: 10pt; font-family: Verdana"><strong>:</strong></span><asp:TextBox
ID="txtname" runat="server" Font-Names="MS Reference Sans Serif"
Width="158px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" valign="top">
Message Type:<asp:TextBox
ID="txtmess" runat="server" Height="60px" TextMode="MultiLine"
Width="154px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" style="height: 35px">
<img src="pr.png" style="height: 29px"/>
<asp:ImageButton ID="ImageButton1" runat="server" Height="36px" ImageUrl="~/send_button.png"
Width="64px" onclick="ImageButton1_Click" /></td>
</tr>
</table>
</div>
Default2.aspx.cs
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
string
msg = (string)Application["msg"];
txtmsg.Text = msg;
}
protected void ImageButton1_Click(object
sender, ImageClickEventArgs e)
{
string
name = txtname.Text;
string
message = txtmess.Text;
string
mymessage = name + "::" + message;
//Appending
the User Entered Data To Application["msg"] object
Application["msg"]
= Application["msg"] + mymessage +
Environment.NewLine;
//Finally
Dispaling on the Chat Content
txtmsg.Text = Application["msg"].ToString();
txtmess.Text = "";
}
}
Default.aspx
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script language="javascript"
type="text/javascript">
function
panku() {
var
newwin=window.open("Default2.aspx",
'method_desc', 'width=300,
height=500, left=350,, top=120')
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div >
<asp:Button ID="b1" runat="server" Text=" Start chat"
OnClientClick="javascript:panku();" Height="23px"
BackColor="#6600CC"
BorderStyle="Groove" ForeColor="White" />
</div>
</asp:Content>

No comments:
Post a Comment