Because to make a registration page, see many Web sites are using Ajax asynchronous refresh to verify that the user name is available, so do a small example yourself
Are simple examples, so direct send code static page ajax.html code as follows: <html> <head> < title>ajax</title> <script type= "Text/javascript" > Function Loadxmldoc () { if (document.geteleme Ntbyid ("Account"). Value = = "" "{ Document.getelement Byid ("Accdiv"). InnerHTML = "User name cannot be empty"; return; var XMLH Ttp if window. XMLHttpRequest) {//code for ie7+ xmlHttp = new XML HttpRequest (); }   ELSE {//code for IE5/IE6 &NBS P XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP"); X Mlhttp.onreadystatechange = function () { if (xmlhtt P.readystate = 4 && xmlhttp.status = { &NBSP ; //document.getelementbyid ("mydiv"). Innerhtml=xmlhttp.responsetext; if (Xmlhttp.responsetext = = "true") { document.getElementById ( "Accdiv"). InnerHTML = "User name not available"; }   else { &NB Sp document.getElementById ("Accdiv") InnerHTML = "User name available"; & nbsp } var a = document.getElementById ("account"). Value; //Get XML Http.open ("Get", "validate.aspx?account=" + A + "&random=" + Math.random, True); xmlhttp.send (); function Deldata () { & nbsp document.getElementById ("account"). Value = ""; document.getElementById ("Accdiv"). InnerHTML = ""; </script> </head> <body> <h3>ajax</h3> <table>   ; <tr> <td> account: </td ><td><input id= "Account" type= "text" onblur= "Loadxmldoc ();" onfocus= "Deldata ();" /></td><td><div id= "Accdiv" ></div></td> </tr> <tr> & lt;td> Password: </td><td><input id= "passwd" type= "password"/></td> & nbsp </tr>   <tr> <td> Confirm password: </ Td><td><input id= "vpasswd" type= "password"/></td> </ tr> <tr> <TD > Name: </td><td><input id= "name" type= "text"/></td> & lt;/tr> </table> </body> </html> in account input When the box loses focus, the call function Access server uses a Get method, so additional random code is used at the parameter to avoid caching. Verification page validate.aspx Background code: The code is as follows: using System; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Configuration; Using SYSTEM.DATA.SQL; Using System.Data.SqlClient; public partial class Ajax_validate_validate:System.Web.UI.Page { Public SqlConnection Conn; protected void Page_Load (object sender, EventArgs e) { RESP Onse. Clear (); if (Exists (request.querystring["account")) Response . Write ("true"); else Response.Write ("false"); Response.End (); } ///<summary> ///Get database connection ///</summary> &nbs P <returns></returns> protected SqlConnection getconnection () { &N Bsp String str = configurationmanager.connectionstrings["ConnectionString"]. ConnectionString; conn = new SqlConnection (str); return conn; } protected bool Exists (string account) { using (getconnection ()) { try & nbsp { Conn. Open (); String sqlstr = "SELECT count (*) from userinfo where account= '" + Account + "'"; SqlCommand cmd = new SqlCommand (SQLSTR, conn); int row = Convert.ToInt32 (cmd. ExecuteScalar ()); if (Row > 0) & nbsp return true; else &NBSP ; return false; catch (Exception e) &N Bsp &nBsp ( throw e; finally { &NBS P Conn. Close (); { } }} verifying username in the background Whether it already exists in the database, return TRUE or false database is very simple, only built a table userinfo, there are 3 fields: Account, passwd, name NOTE: When writing data to the request page in the background, after writing the data to be sent, You need to call the Response.End () method to terminate the write, or you may send a full page past.