ajax实现输入框提示信息

ajax实现输入框提示信息_第1张图片 

HtmlPage1.html


    
    
    


    

请在输入框中输入字母(A-G):


提示:

WebForm1.aspx.cs 

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            string[] a =
            {
                "Asdf","Awet","Bsdf","Bi","Csad","Coew",
                "Dasd","Dfg","Egfd","Efh","Fdsfh","Feth","Gsfgg","Grhf"
            };
            string q = Request.Params["q"].ToUpper();
            string hint = "";
            if (q.Length > 0)
            {
                int i;
                for (i = 0; i < 14; i++)
                {
                    string b = a[i].Substring(0, q.Length);
                    if (q == b)
                    {
                        if(hint == "")
                        {
                            hint = a[i];
                        }
                        else
                        {
                            hint = hint + "," + a[i];
                        }
                    }
                }
            }
            if (hint == "")
            {
                Response.Write("没有提示");
            }
            else
            {
                Response.Write(hint);
            }
            Response.End();
        }

 

 ajax实现输入框提示信息_第2张图片

 

你可能感兴趣的:(Ajax异步请求)