public ValidationResult ValidateUsername(string username, string originalUsername) { // This web service in turns call a WCF service which resides on the same or different systems. ValidationResult result = new ValidationResult(); if (String.IsNullOrEmpty(username)) { result.Success = false; result.ErrorCode = -1; result.ErrorText = ValidationErrors.UsernameCannotBeEmpty; return(result); } UserManagementController controller = new UserManagementController(); if (controller.ExistsUsername(username) && !username.Equals(originalUsername)) { result.Success = false; result.ErrorCode = -1; result.ErrorText = String.Format(ValidationErrors.UsernameAlreadyExists, username); return(result); } else { result.Success = true; } return(result); }
protected override bool OnServerSideEvaluate() { String username = GetControlValidationValue("UserLoginId"); String originalUsername = ((HiddenField)FindControl("OriginalUserLoginId")).Value; if (String.IsNullOrEmpty(username)) { ErrorMessage = ValidationErrors.UserIDCannotBeEmpty; return(false); } var controller = new UserManagementController(); if (controller.ExistsUsername(username) && !username.Equals(originalUsername)) { ErrorMessage = String.Format(ValidationErrors.UsernameAlreadyExists, username); return(false); } return(true); }