protected void btnAdd_Click(object sender, EventArgs e) { // retrieve user info UserEntity user = new UserEntity(txtUserName.Text); using (DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.FetchEntity(user); } // user exist if (!user.IsNew) { // check for valid password if (user.Password == txtPassword.Text) { SessionHelper.AddUserObject(user); Response.Redirect("Default.aspx"); } // wrong password! else { this.lblLoginValidate.Visible = true; } } // user doesn't exist! else { lblLoginValidate.Visible = true; txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; } }