troubleshooting Question 2 check unique email for login user - double points if answer within 2 days

Avatar of cmleung2
cmleung2 asked on
ASP.NETWeb Languages and Standards.NET Programming
5 Comments2 Solutions532 ViewsLast Modified:
I am going to give double points (total of 1000) if I can get the answer quickly.  I really need this done, very urgent.

My website using 2, allow user to login and update their email.  But whenever they do that, if they enter an email already exist for another user, a custom validation occur.  I currently have the code for checking unique email when creating new user using the following:

Dim userCollection As MembershipUserCollection = Membership.FindUsersByEmail(txtboxEmail.Text)
If Page.IsValid Then
            args.IsValid = True
            If userCollection.Count > 0 Then
                args.IsValid = False
            End If
        End If

But this causes the problem when the user press update without changing the email (since the email already exist for the current user).  

I tried to check if the user name from the "FindUserByEmail" is the same with the current user, but couldn't figure out how to do that!
I tried to use an the "MembershipUserCollection.Copyto" to an array, and also tried to use a for loop to loop through each user and add it into the array, but both of them gives me the current user all the time even when I enter an email for another user)

My "testing" code so far to attempt this check is as follow:
 Protected Sub CheckUniqueEmail(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
        Dim userCollection As MembershipUserCollection = Membership.FindUsersByEmail(txtboxEmail.Text)
        Dim arruser As ArrayList = New ArrayList()
        Dim member As MembershipUser
        For Each member In userCollection
     End Sub

Any help will be greatly appreciate.  If you have any points request, give me an offer.  As I said, I really need to get this over and done with, it's been more than 10 hours I am on this stupid thing.  Thanks


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 5 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004