• 来个异步查询用户名是否存在


    来个异步查询用户名是否存在
    index.aspx

    HTML code 

    <script type="text/javascript" language="javascript">
            function validateloginname()
            {
                var loginname=document.getElementById("Text1").value;

                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                xmlHttp.onreadystatechange=getdata;
                xmlHttp.Open("GET","validate.aspx?loginname="+loginname,true);
                xmlHttp.Send();
            }
            function getdata()
            {
                if(xmlHttp.readystate==4)
                {
                    if(xmlHttp.status==200)
                    {
                        var text=xmlHttp.responseText;
                        if(text=="1")
                        {
                            document.getElementById("td1").innerHTML="用户名已存在";
                            document.getElementById("Text1").style.borderColor="Black";
                            document.getElementById("Text1").focus();
                             document.getElementById("Text1").value="";
                        }
                        else
                        {
                             document.getElementById("td1").innerHTML="OK";
                             document.getElementById("Text1").style.borderColor="Red";
                        }
                    }
                }
            }
        </script>

     <td>
                        <input id="Text1" type="text" runat="server" onblur="validateloginname()" />
                    </td>
                    <td id="td1">
                       
                    </td>




    validate.aspx

    C# code 

        protected void Page_Load(object sender, EventArgs e)
        {
            string loginname = Request.QueryString["loginname"];

            if (loginname == "mcluzhi")
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }
  • 相关阅读:
    技术沙龙.:主题为《代码解析Castle(IOC)应用实例 -开源CMS 系统Cuyahoga》
    Active Record和Domain Object + Dao
    SNMP++.NET 项目
    微软发布Windows Vista Tips and Tricks网站
    2007 Office System Video
    使用搜索引擎搜索结果
    我购买了一台acer笔记本
    有价值的杂志《MSDN杂志》中文版
    Spring2.0中文参考手册(中文版) [转自CSDN论坛]
    开源项目Generics.Net介绍
  • 原文地址:https://www.cnblogs.com/chaoa/p/2331337.html
Copyright © 2020-2023  润新知