• Ajax练习:使用jQuery验证用户名是否存在


    1.页面部分


    用户名:<asp:TextBox ID="txtId" runat="server"></asp:TextBox>

    <asp:Label ID="lblShow" runat="server" ForeColor="Red"></asp:Label>

    2.编写javascript脚本部分

    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    
    <script type="text/javascript">
    $(function () {
    $("#txtId").blur(function () {
    var a = $("#txtId").val();
    $.ajax({
    type: "post",
    url: "Handler1.ashx",
    data: { m: a },
    success: function (result) {
    var res = result.toString();
    $("#lblShow").html(res);
    }
    });
    });
    });
    </script>

    3.ashx中代码

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                string Name = context.Request.Params["m"].ToString();
    
                if (AdminManager.nameIsExist(Name) == ture)
                {
                    context.Response.Write("此用户名已被注册!");
                }
                else
                {
                    context.Response.Write("此用户名可以使用!");
                }
            }
  • 相关阅读:
    sql server 2008 安装过程与创建建sql server登录用户
    Angularjs之controller 和filter(四)
    Angularjs之表单实例(三)
    antlr应用
    antlr4笔记(转)
    go升级版本
    go安装依赖包
    tsar
    java纤程
    HighLevelRestApi管理ES
  • 原文地址:https://www.cnblogs.com/xyangs/p/3843926.html
Copyright © 2020-2023  润新知