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
Our community of experts have been thoroughly vetted for their expertise and industry experience.