后台代码:

protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
        this.textbox1.Attributes.Add("OnKeyUp", "VerifyDescription(this.value)");
    }

    [AjaxMethod()]
    public string InnerLength(string str)
    {
        if (str.Length <= 0 || str.Length > 10)
        {
            return "0";
        }
        else
        {
            return "1";
        }
    }



前台调用代码:
<script language="javascript">
        function verifyDescription_callback(result)
        {
            var msg= document.getElementById('lblMsg');
            var value=result.value;
            if(value=='0')
            {
                msg.innerText="输入请长度介于0到10之间";
            }
            else if(value=='1')
            {
                msg.innerText="输入正确";
            }
            else
            {
                msg.innerText="输入争取的啊";
            }
        }
       
        function VerifyDescription(tvalue)
        {
            _Default.InnerLength(tvalue,verifyDescription_callback);
        }
    </script>


配置文件里面天极节点:
      <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" />
posted on 2008-03-04 00:36  weifan  阅读(194)  评论(0)    收藏  举报