Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // using QueryString
            //if (Request.QueryString["status"] != null &&
            //    Request.QueryString["status"].ToString() == "Login")
            //{
            //}

            if (Session["status"] != null &&
                Session["status"].ToString() == "Login")
            {
                //successful login

                // to create a new instance from a class
                // X varName = new X();

                DataSet1TableAdapters.MyUsersTableAdapter taUsers = new DataSet1TableAdapters.MyUsersTableAdapter();
                string UName = taUsers.getNameByUsername(Session["username"].ToString());

                lblTitle.Text = UName + " به سایت من خوش اومدی";
            }
            else
            {
                Response.Redirect("login.aspx");
            }
        }
Exemplo n.º 2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     DataSet1TableAdapters.MyUsersTableAdapter usda = new DataSet1TableAdapters.MyUsersTableAdapter();
     usda.Insert(txtUsername.Text, txtPass.Text, txtName.Text);
     txtUsername.Text = txtPass.Text = "";
     btnAdd.Text      = "اطلاعات ثبت شد!";
 }
Exemplo n.º 3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DataSet1TableAdapters.MyUsersTableAdapter users = new DataSet1TableAdapters.MyUsersTableAdapter();
            int numberOfUsers = users.LoginQuery(txtUser.Text, txtPass.Text).GetValueOrDefault();

            if (numberOfUsers > 0)
            {
                // login successful!
                Session.Add("status", "Login");
                Response.Redirect("Default.aspx");

                // using QueryString
                //Response.Redirect("Default.aspx?status=Login");
            }
            else
            {
                // Failed!
                txtPass.Text        = "";
                txtUser.Text        = "";
                lblErr.Text         = "Login failed! Please try again!";
                txtUser.BorderColor = System.Drawing.Color.Red;
            }
        }