private void LoginUser() { //if fore-color of a textBox is not black, that means the textbox //contains the placeholder text and user didn't enter any value string username = UsernameTextBox.ForeColor == Color.Black? UsernameTextBox.Text : ""; string password = PasswordTextBox.ForeColor == Color.Black? PasswordTextBox.Text : ""; if (username.Length < 1) { ShowErrorMessage("Please enter username."); return; } else if (password.Length < 1) { ShowErrorMessage("Please enter password."); return; } //disable all controls so that the user cannot //change anything until the login process ends DisableAllControls(); //show progress bar string status = "Verifying your login credentials, please wait..."; ProgressViewerForm progressViewer = new ProgressViewerForm(status); progressViewer.Location = new Point(this.Location.X + 70, this.Location.Y + 100); progressViewer.Show(); _progressViewerObject = progressViewer; //send web request to verify user's login credentials WebHandler webRequest = new WebHandler(); webRequest.WebRequestSuccessEventHandler += OnLoginSuccess; webRequest.WebRequestFailedEventHandler += OnLoginFailed; _webHandlerObject = webRequest; webRequest.AuthenticateUser(username, password); }