Home > ASP.Net > Check UserName Availability

Check UserName Availability


Hi

try this example to Check UserName availability using Membership via Code:

 //-- To check user name availability
         if (txt_User.Text.Length != 0)
            {
                MembershipUser user = Membership.GetUser(txt_User.Text);
                if (user != null)
                {
                    lblMsg.Text = "User " + txt_User.Text + " is already Exist";
                    lblMsg.ForeColor = Color.Red;
                }
                else
                {
                    lblMsg.Text = "User " + txt_User.Text + " is available";
                    lblMsg.ForeColor = Color.Green;
                }
            }
            else
            {
                lblMsg.Text = "Please Enter user Name";
                lblMsg.ForeColor = Color.Red;

            }

Good Luck

Advertisements
Categories: ASP.Net
  1. December 27, 2008 at 7:03 pm

    This code works fine one thing paste into a
    note pad first to remove formating
    Thanks

  2. yasserzaid
    December 28, 2008 at 3:06 pm

    Hi Rick thanks for your comment
    and hope this post helps you

    you can also check this post to check username availability using ajax

    https://yasserzaid.wordpress.com/2008/12/28/check-username-availability-with-ajax/

    Best Regards

    YZ

  3. December 31, 2008 at 6:28 am
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: