Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created November 21, 2017 14:58
Show Gist options
  • Save sjehutch/9f50d0301f29853dffdd757b4e528279 to your computer and use it in GitHub Desktop.
Save sjehutch/9f50d0301f29853dffdd757b4e528279 to your computer and use it in GitHub Desktop.
check for null entry textbox xamarin
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