温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:我的Asp.net三层聊天室源码
当前文件路径:MyChatRoom/Speak.aspx.cs

1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
12
using MyChatRoom.BusinessLogicLayer; 13
//该源码下载自www.51aspx.com(51aspx.com) 14
15
namespace MyChatRoom.WebLayer 16
{ 17
/// <summary> 18
/// Speak 的摘要说明。 19
/// </summary> 20
public partial class Speak : System.Web.UI.Page 21
{ 22
23
protected void Page_Load(object sender, System.EventArgs e) 24
{ 25
// 在此处放置用户代码以初始化页面 26
} 27
28
/// <summary> 29
/// 用户单击“发言”时的事件 30
/// </summary> 31
/// <param name="sender"></param> 32
/// <param name="e"></param> 33
protected void ButtonSpeak_Click(object sender, System.EventArgs e) 34
{ 35
//获取用户输入的发言信息 36
string userName=Session["user_name"].ToString(); //用户名 37
string createTime=System.DateTime.Now.ToLongTimeString();//发言时间 38
string content=TextBoxContent.Text; //发言内容 39
string color=DropDownListColor.SelectedItem.Value; //颜色 40
string emotion=DropDownListEmotion.SelectedItem.Value; //表情 41
42
43
Message message=new Message(); //实例化Message类 44
message.Add(userName,createTime,content,color,emotion); //利用Message类的Add方法,向数据库添加留言 45
//清空发言框 46
TextBoxContent.Text=""; 47
} 48
49
/// <summary> 50
/// 用户单击“离开”时的事件 51
/// </summary> 52
/// <param name="sender"></param> 53
/// <param name="e"></param> 54
protected void ButtonExit_Click(object sender, System.EventArgs e) 55
{ 56
Session["user_name"]=null; //销毁Session中的用户信息 57
Response.Write("<Script Language=JavaScript>window.top.location=\"Login.aspx\";</Script>"); 58
} 59
} 60
} 61





}