protected void Logon_Click(object sender, EventArgs e) { TextBox userName = (TextBox)Page.FindControl("UserEmail"); TextBox password = (TextBox)Page.FindControl("UserPassword"); if (DB.AccessIsAllowed(userName.Text, password.Text)) { CheckBox persist = (CheckBox)Page.FindControl("Persist"); FormsAuthentication.RedirectFromLoginPage (userName.Text, persist.Checked); } else { Label errorMessage = (Label)Page.FindControl("ErrorMessage"); errorMessage.Text = "Invalid credentials. Please try again."; } }