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

📄 login.aspx.cs

📁 ajax+visalsdio2005实现的聊天室程序
💻 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;
using Cnblogs.Ajax;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

	protected void btnLogin_Click(object sender, EventArgs e)
	{
		string userName = this.txtUserName.Text.Trim();
		string password = this.txtPassword.Text.Trim();
		string retypePwd = this.txtRetypePwd.Text.Trim();

		if (password == "")
		{
			this.lblMessage.Text = "密码不能为空";
		}
		else if (password != retypePwd)
		{
			this.lblMessage.Text = "两遍密码必须相同";
		}
		else if (!ChatRoom.Instance.UserIsChatting(userName))
		{
			this.LoginUser(userName, password);
		}
		else if (ChatRoom.Instance.GetUser(userName).Password != password)
		{
			this.lblMessage.Text = "您已经登陆,请输入正确密码";
		}
		else
		{
			this.LoginUser(userName, password);
		}
	}

	private void LoginUser(string userName, string password)
	{
		if (!ChatRoom.Instance.UserIsChatting(userName))
		{
			ChatRoom.Instance.AddUser(userName, password);
			ChatRoom.Instance.SendMessage(
				"*系统*",
				String.Format("{0} 进入了聊天室", userName));
		}

		ChatRoom.Instance.GetUser(userName).Update();
		FormsAuthentication.RedirectFromLoginPage(userName, false);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -