?? chat.aspx.cs
字號:
?using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class chat : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Application.Lock();
string[] user = (string[])Application["user"];
Application.UnLock();
for (int i = 0; i < user.Length; i++)
{
this.lbUser.Items.Add(user[i]);
}
Application.Lock();
string[] user1 = (string[])Application["user"];
Application.UnLock();
int k = 0;
int length = 0;
while (user1[k] != null)
{
length++;
k++;
}
for (int j = 0; j < length; j++)
{
this.ddlUser.Items.Add(user1[j]);
}
Application.Lock();
string[] message = (string[])Application["message"];
int a = 0;
int b = 0;
while (message[a] != null)
{
b++;
a++;
}
string info = null;
for (int c = 0; c < b; c++)
{
info = info + message[c] + "\n";
}
Application.UnLock();
this.txtInfo.Text = info;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string userName = (string)Session["userName"];
Session.Clear();
Application.Lock();
string[] user = (string[])Application["user"];
int i = 0;
int length = 0;
while (user[i] != null)
{
length++;
i++;
}
for (i = 0; i < length; i++)
{
if (user[i].Equals(userName))
{
for (int j = i; j < length; j++)
{
user[j] = user[j + 1];
}
}
}
Application.Add("user", user);
Application.UnLock();
this.lbUser.Items.Remove(userName);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string message = (string)Session["userName"] + "對" + this.ddlUser.Text + "說:" + txtMessage.Text;
Application.Lock();
string[] message1 = (string[])Application["message"];
int i = 0;
int length = 0;
while (message1[i] != null)
{
length++;
i++;
}
message1[i] = message;
Application.Add("message", message);
Application.UnLock();
Application.Lock();
string[] message2 = (string[])Application["message"];
int a = 0;
int b = 0;
while (message2[a] != null)
{
b++;
a++;
}
string info = null;
for (int c = 0; c < b; c++)
{
info = info + message2[c] + "\n";
}
Application.UnLock();
this.txtInfo.Text = info;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -