Beispiel #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var dl = dt.DangNhap_Search(txtUserName.Text, txtPassWord.Text);
            int kt = dl.Count();

            if (kt > 0)
            {
                Session["admin"] = true;
                Response.Redirect("index.aspx");
            }
            else
            {
                lblThongBao.Text = "Đăng Nhập Thất Bại ";
                txtUserName.Text = "";
                txtPassWord.Text = "";
                txtUserName.Focus();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                String txtUserName = Request.Form["txtuser"];
                String txtPassWord = Request.Form["txtpassword"];


                var dl = dt.DangNhap_Search(txtUserName, txtPassWord);
                int kt = dl.Count();
                if (kt > 0)
                {
                    Session["admin"] = true;
                    Response.Redirect("index.aspx");
                }
                else
                {
                    txtUserName     = "";
                    txtPassWord     = "";
                    lbthongbao.Text = "Đăng nhập thất bại";
                }
            }
        }