troubleshooting Question

asp.net 2 check unique email for login user - double points if answer within 2 days

Avatar of cmleung2
cmleung2 asked on
Web Languages and Standards.NET ProgrammingASP.NET
5 Comments1 Solution532 ViewsLast Modified:
Hi,
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 asp.net 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
            MsgBox(member.UserName)
            arruser.Add(member.UserName)
        Next
        MsgBox(arruser.Item(0).ToString)
     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

Cecilia
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros