protected void btnRegister_Click(object sender, EventArgs e) { try { //1. here we need to double check the validations that may or may not have been done //on the client in case javascript is disabled for example - done because i added asp.net //validator controls that do server validations including the username in use check using //a customvalidator control //2. here we also need to make sure the input is not malicious, for FName, LName, ZipCode, //and Address - i guess we could go up to 255 characters for address //still pushing it though bool validInput = false; string errors = null; validInput = ValidateInputFields(txtFirstName.Text, txtLastName.Text, txtMiddleInitials.Text, txtZipCode.Text, txtStreetAddress.Text, out errors); if (validInput) { //3. We need to call the method to actually submit a registration to the registration // service which will then create an account profile and other dependent objects bool registrationSuccess = _registrationPresenter.Register(txtUsername.Text, txtPassword.Text, txtFirstName.Text, txtMiddleInitials.Text, txtLastName.Text, txtStreetAddress.Text, txtZipCode.Text, ddlCountry.SelectedItem.Text, ddlCity.SelectedItem.Text, this.txtHomePhone.Text, this.txtMobilePhone.Text, this.txtEmail.Text, new ProfileType() { ProfileTypeID = new Guid(ddlProfileType.SelectedItem.Value), ProfileName = ddlProfileType.SelectedItem.Text }); //4. We need to verify the captcha control has the correct answer - done i did this using // a custom validation control that checks the captcha Text property for True //5. IF all is well then we also need to login the user and redirect them to the // Default.aspx page if (registrationSuccess) { bool loginSuccess = _accountPresenter.LoginAndRedirect(txtUsername.Text, txtPassword.Text); //if we got here login was not successful so it will prompt them to login when they get //to the default.aspx page Response.Redirect("~/Default.aspx"); } else { lblErrors.Text = "Sorry there was an error and your registration was not successful"; } } else { this.lblErrors.Text = "Please fix the following Errors: " + Environment.NewLine + errors; } } catch (Exception) { lblErrors.Text = "Sorry there was an error and your registration was not successful"; } }