//handle the event when clicking the button protected void BtnRegistration(object sender, EventArgs e) { User_DAL Userdal = new User_DAL(); string UID = txtUserID.Text; string UserName = txtUserName.Text; string Password = txtPassword.Text; string ConfirmPassword = txtConfirmPassword.Text; //validations for input if (Password != ConfirmPassword) { ShowMessage("Please type the same password to confirm!"); } else if (string.IsNullOrEmpty(UID) || string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(ConfirmPassword)) { ShowMessage("Please fill all fields to finish the registration!"); } else { Userdal.RegisterUser(UID, UserName, Password); Response.Redirect("UserLogin.aspx"); } }
protected void BtnResetPwd(object sender, EventArgs e) { User_DAL aLayer = new User_DAL(); var NewPassword = aLayer.ResetPassword(txtUserID.Text, txtUserName.Text); lblMessage.Text = "Your password has been reset to: " + NewPassword; }
protected void UserLogin(object sender, EventArgs e) { User_DAL aLayer = new User_DAL(); //check local if (aLayer.LoginUser(txtUsername.Text, txtPassword.Text)) { if (txtUsername.Text.Equals("admin")) { Response.Redirect("AdminData.aspx"); } else { Response.Redirect("Home.aspx"); } } else { lblMsg.Visible = true; lblMsg.Text = "Wrong username or password, Please try again"; } }