async protected void RegisterNewUser(object sender, EventArgs e) { if (Password.Text != Reenter.Text) { Message.Text = "The passwords do not match. Re-enter the passwords."; Password.Text = ""; Reenter.Text = ""; return; } try { if (Useremail.Text == "" || Username.Text == "" || Password.Text == "" || Reenter.Text == "" || FirstName.Text == "" || LastName.Text == "") { Message.Text = "None of the values can be empty."; return; } var exists = CheckIfUserAlreadyExists(Useremail.Text); if (exists) { Message.Text = "You already have an account. Go back and login!"; return; } if (String.IsNullOrEmpty(Recaptcha1.Response)) { Message.Text = "Captcha cannot be empty."; return; } else { RecaptchaVerificationResult result = await Recaptcha1.VerifyTaskAsync(); if (result == RecaptchaVerificationResult.Success) { StoreData(Username.Text, Password.Text, "Member", FirstName.Text, LastName.Text, Useremail.Text); Message.Text = "Registration complete."; GoBack.Visible = true; return; } else if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution) { Message.Text = "Incorrect captcha response."; } else { Message.Text = "Some other problem with captcha."; } } } catch (Exception exception) { Message.Text = "Could not register. Try again." + exception; } }
protected async void btnSubmit_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(Recaptcha1.Response)) { lblMessage.Text = "Captcha cannot be empty."; } else { RecaptchaVerificationResult result = await Recaptcha1.VerifyTaskAsync(); if (result == RecaptchaVerificationResult.Success) { Response.Redirect("Welcome.aspx"); } if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution) { lblMessage.Text = "Incorrect captcha response."; } else { lblMessage.Text = "Some other problem with captcha."; } } }