Exemple #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        msg.Visible = true;
        try
        {
            AdminLogin al = new AdminLogin();
            db.dt = al.CheckAdmin(username.Text, password.Text);

            if (db.dt.Rows.Count > 0)
            {
                Session["usernames"] = username.Text;
                Session["password"]  = password.Text;
                Session["roles"]     = db.dt.Rows[0]["role"].ToString();
                Response.Redirect("index.aspx");
            }
            else
            {
                msg.Text      = "invalid username or password";
                msg.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            ltrmsg.Text = ex.Message;
        }
    }