⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chat.aspx.cs

📁 械非机动车在此厅局级在此要求在要求厅在要在此枯黄可耕地枯喜鹊土木工程在
💻 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 + -