Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Validate email duplication during membership registration

Validate email duplication during membership registration

Scheduled Pinned Locked Moved ASP.NET
databaseregexhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Albert83
    wrote on last edited by
    #1

    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; } }

    G 1 Reply Last reply
    0
    • A Albert83

      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; } }

      G Offline
      G Offline
      Gayani Devapriya
      wrote on last edited by
      #2

      Hi, Try to CreateUserWizard1_CreatingUser event. Thx, Gayani

      A 1 Reply Last reply
      0
      • G Gayani Devapriya

        Hi, Try to CreateUserWizard1_CreatingUser event. Thx, Gayani

        A Offline
        A Offline
        Albert83
        wrote on last edited by
        #3

        Thank you for the advice. As it turns out the membership control has a built in mechanism for it. I just recreated the control and it works.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups