Asp.net AjaxProc 使用示例1

使用asp.net Ajax 方法,大概分三步骤:

示例如下:

1.页面注册

AjaxPro.Utility.RegisterTypeForAjax(typeof(Login_Register1));

2.

cs文件里面方法书写:

 [AjaxPro.AjaxMethod]
    public string ValideName(string strname)
    {
        string partten = @"[u4e00-u9fa5]";

        if (strname == "")
        {
            return "-2";
        }
        if (!Regex.IsMatch(strname, partten))
        {
            return "-1";
        }
        else
        {
            if (strname.Length < 6 || strname.Length > 20)
            {
                return "-3";
            }
            if (Register.isExistName(strname))
            {
                return "1";
            }
            else
            {
                return "0";
            }
        }

    }

3.前台调用:

Login_Register2.ValideName(document.getElementById("txtname").value,ValideName_callback);

你可能感兴趣的:(asp.net)