.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Checking username availability using ajax

Posted By:Gowthammanju       Posted Date: July 30, 2011    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

These article explain about checking whether user name exists or not using ajax in asp.net

Just follow this steps;

download the ajax tool kid from the attached file here

import the assembly to ur project by adding these lines in aspx page
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="ajax" %>

add script manager to the body as

place update panel from ajax extensions and content template as below

now create the table in between the content template and use coding as


in aspx.cs page import name space for sql as

using System.Data.SqlClient;

now write the coding in the text changed field of user name textbox as

if (!string.IsNullOrEmpty(txtUsername.Text))
SqlConnection con = new SqlConnection("your connection string");
SqlCommand cmd = new SqlCommand("select * from ssg where UserName=@Name", con);
cmd.Parameters.AddWithValue("@Name", txtUsername.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
checkusername.Visible = true;
imgstatus.ImageUrl = "NotAvailable.jpg";
lblStatus.Text = "UserName Already Taken";
checkusername.Visible = true;
imgstatus.ImageUrl = "Icon_Available.gif";
lblStatus.Text = "UserName Available";
checkusername.Visible = false;
thats it....

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend