/// <summary> /// Handles the Submit button-click events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Submit_Click(object sender, System.EventArgs e) { try { if (EditUserInfoControl1.Page.IsValid) { UsersControl.updateUser(EditUserInfoControl1.UserInfo); Response.Redirect("MyAccount.aspx?message=User information updated successfully.", true); } } catch (Exception ex) { ErrorMessage.Text = ex.Message; } }
private void SubmitBtn_Click(object sender, System.EventArgs e) { // Try to retrieve user information with the given username UserAccounts.UserInfo user = UserAccounts.getUserInfo(txtUserName.Text); // Check if the user actually exists if (user == null) { lblMessage.Text = "Username not found."; } else { int index = secretQuestion.getQuestionID(); // Check that the secret question and answer were right if (user.QuestionID != index || user.QuestionAnswer != secretQuestion.getAnswer()) { lblMessage.Text = "Some or all of the data you entered was " + "incorrect. Please revise your answers and try again. "; } else { // generate a password string newPwd = generatePassword(); // set the password in the database user.Password = newPwd; UsersControl.updateUser(user); // send it to their email Email email = Emails.getEmail(EmailType.PasswordReset); Emails.formatEmail(email, user.Username, newPwd); MailMessage msg = Emails.constructMailMessage(email, user.Username, Globals.AdminsEmail); SmtpMail.SmtpServer = AspNetForums.Components.Globals.SmtpServer; SmtpMail.Send(msg); // give them further instructions and set the visibility // of the command buttons accordingly lblMessage.Text = "An email has been sent to: " + user.Email + ". Please check your email for your new password. " + "You may change this password after you log in. " + "Click Continue to go to the login page. "; SubmitBtn.Visible = false; ContinueBtn.Visible = true; } } }