protected void CheckPasswordLength(object source, ServerValidateEventArgs args) { string password = args.Value.Trim(); bool isLengthOK = false; isLengthOK = ((password.Length >= int.Parse(ConfigurationManager.AppSettings["MinimumPasswordSize"])) && (password.Length <= int.Parse(ConfigurationManager.AppSettings["MaximumPasswordSize"]))) ? true : false; args.IsValid = isLengthOK && PasswordChecker.IsStrongPassword(password); }
protected void cvVerifyPasswords_ServerValidate(object source, ServerValidateEventArgs args) { // check if current password is correct if (EncryptionHelper.Encrypt(args.Value) == Session[Constant.SESSION_PASSWORD].ToString()) { // check if new password is a strong password cvVerifyPasswords.ErrorMessage = "Password is weak.<br />"; args.IsValid = (PasswordChecker.IsStrongPassword(txtNewPwd.Text.Trim())); } else { cvVerifyPasswords.ErrorMessage = "Invalid current password.<br />"; args.IsValid = false; } }