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


Top 5 Contributors of the Month
david stephan

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

UserName:

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");
con.Open();
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";
}
else
{
checkusername.Visible = true;
imgstatus.ImageUrl = "Icon_Available.gif";
lblStatus.Text = "UserName Available";
}
}
else
{
checkusername.Visible = false;
}
thats it....


cheers.....
 Subscribe to Articles

     

Further Readings:

Responses

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