ajax异步获取数据,查询用户数据 
<script type="text/javascript"> 
    var xmlHttp; 
    function createXMLHttpRequest() 
    { 
        if(window.ActiveXObject) 
        { 
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        else if(window.XMLHttpRequest) 
        { 
            xmlHttp = new XMLHttpRequest(); 
        } 
    } 
    function CheckUserName() 
    { 
      var us=document.getElementById("txtname").value; 
      if(us!="") 
      { 
        createXMLHttpRequest(); 
        var url= "RegistValidate.ashx?username="+escape(document.getElementById("txtname").value); 
        xmlHttp.open("GET",url,true); 
        xmlHttp.onreadystatechange=ShowResult; 
        xmlHttp.send(null); 
        } 
    } 
    function ShowResult() 
    { 
        if(xmlHttp.readyState==4) 
        { 
            if(xmlHttp.status==200) 
            { 
                var s; 
                s=xmlHttp.responseText; 
                  alert(s); 
            } 
        } 
    } 
</script> 或 
this.txt_Id.Attributes.Add("onblur", "check(this.value)");   function check(id) { 
            if (id == "") 
                return; 
          document.getElementById("id_msg").innerHTML = " 检查中,请稍候……"; 
            var url = "../RegistValidate.ashx?username=" + escape(id); 
            xmlHttp.open("GET", url, true); 
            xmlHttp.onreadystatechange = ShowResult; 
            xmlHttp.send(null); 
        } 
        function ShowResult() { 
            
            if (xmlHttp.readyState == 4) { 
                if (xmlHttp.status == 200) { 
                    var s; 
                    s = xmlHttp.responseText; 
                    if (s== "OK") 
                        document.getElementById("userid_msg").innerHTML = "";                    else 
                        document.getElementById("id_msg").innerHTML = ""; 
                    
                } 
                else { 
                    document.getElementById("id_msg").innerHTML =  xmlHttp.status; 
                } 
            } 
        } <asp:textbox id="txt_Id" runat="server" Width="70%"  MaxLength="20"> </asp:textbox> <span id="id_msg"> </span>