JQuery UI AutoComplete automatically completes use of small kee _jquery

Source: Internet
Author: User
Tags jquery ui autocomplete
Page:
Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codefile= "Test.aspx.cs" inherits= "Web_test"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Testing </title>
<link type= "Text/css" rel= "stylesheet"/>
<link href= ". /css/jquery.ui.all.css "rel=" stylesheet "type=" Text/css "/>"
<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" ></ Script>
<!--resolution Drop-down list box is obscured Jquery.bgiframe-->
<script type= "Text/javascript" language= JavaScript "src=". /js/jqui/jquery.bgiframe-2.1.1.js "></script>
<script type= "Text/javascript" language= JavaScript "src=". /js/jqui/jquery.ui.core.js "></script>
<script type= "Text/javascript" language= JavaScript "src=". /js/jqui/jquery.ui.widget.js "></script>
<script type= "Text/javascript" language= JavaScript "src=". /js/jqui/jquery.ui.mouse.js "></script>
<!--Jquery.ui.autocomplete-->
<script type= "Text/javascript" language= JavaScript "src=". /js/jqui/jquery.ui.autocomplete.js "></script>
<script language= "javascript" type= "Text/javascript" >
$ (function () {
$ ("#txtTest"). AutoComplete ({
Minlength:1,
Source:function (Request, Response) {
$.ajax ({
URL: ".. /ajax/getallwords.ashx ",
DataType: "JSON",
Data:request,
Success:function (data) {
Response (data);
}
});
}
});
});
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<input id= "Txttest" type= "text"/>
</div>
</form>
</body>

Background:
Copy Code code as follows:

<%@ WebHandler language= "C #" class= "Getallwords"%>
Using System;
Using System.Web;
public class Getallwords:ihttphandler
{
public void ProcessRequest (HttpContext context)
{
if (context. request.querystring["term"]!= null && context. request.querystring["term"]!= "")
{
Context. Response.Clear ();
Context. Response.Charset = "Utf-8";
Context. Response.Buffer = true;
Context. response.contentencoding = System.Text.Encoding.UTF8;
Context. Response.ContentType = "Text/plain";
Context. Response.Write (Getlikeusername) (context. request.querystring["term"]);
Context. Response.Flush ();
Context. Response.close ();
Context. Response.End ();
}
}
<summary>
Splicing JSON
</summary>
<param name= "key" > Keyword </param>
<returns></returns>
private string Getlikeusername (String key)
{
JHG. Bll.web_wordmanager Wordmanager = new JHG. Bll.web_wordmanager ();
Search, return 10 keywords
string[] Listword = Wordmanager.getsearchword (key, 10);
System.Text.StringBuilder sbstr = new System.Text.StringBuilder ("[");
int ct = listword.length;
for (int i = 0; i < ct; i++)
{
Sbstr. Append ("\" "+ Listword[i] +" "");
if (i = = ct-1)
Sbstr. Append ("]");
Else
Sbstr. Append (",");
}
Return SBSTR. ToString ();
}
public bool IsReusable
{
Get
{
return false;
}
}
}

Note:
File: Jquery.ui.autocomplete.css
. ui-autocomplete {position:absolute; cursor:default;}
Remove: Position:absolute;
Effect Chart:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.