Greetings folks,
I am in the process of learning .NET. Now I'm not one to complain about the ease of .NET however, "Membership" has made life both easy and a little more difficult (call me a control freak as I am a Java / J2EE programmer by nature). I am having some issues here. I am trying to do some checks in the database whether or not a Username has already been used. Now I have already set the database up for membership and I am able to login with a test user I created, but I am having some issues with the coding behind it.
The company I work for is bent on using membership instead of knowing how to do it the ..."old school" way.
I have included a code snippet that I have written. This is when a new user is registering and inputs the Username, it needs to check the database to see if the Username is unique and create a message on the page if the username is already used. What am I missing here? Doesn't this return a collection of users that the username "matches" up with?
Without telling me how (because I am assuming that I am wrong here) can someone nudge me in the right direction? I really want to figure this out, but I don't want someone to say "this is what you do" and write the code for me.
This GetUser says it returns information of the specified user. I don't want a collection of data, I want one single userid. Is this possible with the following code or am I going down the wrong path?
if (Membership.GetUser(tbxNewUserName.Text) == null)
{
lblError.Visible = true;
lblError.Text = "Username already in use, choose another";
tbxNewUserName.Text = "";
}
Thanks in advance for any insight you can provide!
- Josh