Created
November 21, 2017 14:58
-
-
Save sjehutch/9f50d0301f29853dffdd757b4e528279 to your computer and use it in GitHub Desktop.
check for null entry textbox xamarin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void btnSign_touchUp(object sender, EventArgs e) | |
| { | |
| if (!IsValid) | |
| { | |
| var okAlertController = UIAlertController.Create("Alert", _validationError, UIAlertControllerStyle.Alert); | |
| okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => { })); | |
| UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(okAlertController, true, null); | |
| return; | |
| } | |
| //Check that the email and password are not empty | |
| private bool IsValid | |
| { | |
| get | |
| { | |
| var isValid = false; | |
| if (String.IsNullOrWhiteSpace(txtUserName.Text) || String.IsNullOrWhiteSpace(txtPassword.Text) ) | |
| { | |
| _validationError = "Email or Username and Password is required."; | |
| } | |
| else | |
| { | |
| _validationError = String.Empty; | |
| isValid = true; | |
| } | |
| return isValid; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment