Validate email duplication during membership registration
-
Hi, I am trying to check if an email exists in the database during the registration process. I have created a regular expression with ID ValEmail. The following code should do the checking but I don't know the correct place for it. CreateUserWizard1_CreatedUser fires only after the account was created. Any help would be appreciated. protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { TextBox UserNameTextBox = (TextBox)CreateWizardStep1.ContentTemplateContainer.FindControl("UserName"); TextBox EmailTextBox = (TextBox)CreateWizardStep1.ContentTemplateContainer.FindControl("Email"); MembershipUserCollection usersList = Membership.FindUsersByEmail(EmailTextBox.Text); foreach (MembershipUser userEmail in usersList) { if (EmailTextBox.Text == userEmail.Email) { RegularExpressionValidator ValEmail = (RegularExpressionValidator)CreateWizardStep1.ContentTemplateContainer.FindControl("REemailExists"); ValEmail.Visible = false; break; } }
-
Hi, I am trying to check if an email exists in the database during the registration process. I have created a regular expression with ID ValEmail. The following code should do the checking but I don't know the correct place for it. CreateUserWizard1_CreatedUser fires only after the account was created. Any help would be appreciated. protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { TextBox UserNameTextBox = (TextBox)CreateWizardStep1.ContentTemplateContainer.FindControl("UserName"); TextBox EmailTextBox = (TextBox)CreateWizardStep1.ContentTemplateContainer.FindControl("Email"); MembershipUserCollection usersList = Membership.FindUsersByEmail(EmailTextBox.Text); foreach (MembershipUser userEmail in usersList) { if (EmailTextBox.Text == userEmail.Email) { RegularExpressionValidator ValEmail = (RegularExpressionValidator)CreateWizardStep1.ContentTemplateContainer.FindControl("REemailExists"); ValEmail.Visible = false; break; } }
Hi, Try to CreateUserWizard1_CreatingUser event. Thx, Gayani
-
Hi, Try to CreateUserWizard1_CreatingUser event. Thx, Gayani