JS Script Reference
Copy Code code as follows:
<script src= "/scripts/jquery.autocomplete/jquery.autocomplete.js" type= "Text/javascript" ></script>
Style reference
Copy Code code as follows:
<style type= "Text/css" media= "All" >
@import url ("/scripts/jquery.autocomplete/css/jquery.autocomplete.css");
</style>
JS Code
Copy Code code as follows:
? $ (document). Ready (function () {
$ ("#<%=_searchkeygame.clientid%>"). AutoComplete ("./ajaxhandle/autocomplete.ashx?type=game", {
minchars:0,
Max:9,
width:150,
Matchcontains:true,
Autofill:false,
Formatitem:function (row, I, max) {
return row.name;
},
Formatmatch:function (row, I, max) {
return row.name + "";
},
Formatresult:function (Row) {
return row.name;
}
});
JQuery ("#<%=_searchkeygame.clientid%>"). Result (function (event, data, formatted) {
if (data) {
JQuery ("#_SearchKeyGame"). attr ("value", data.name);
}
else {
}
});
$ ("#<%=_searchkeyplat.clientid%>"). AutoComplete ("./ajaxhandle/autocomplete.ashx?type=plat", {
minchars:0,
Max:9,
width:150,
Matchcontains:true,
Autofill:false,
Formatitem:function (row, I, max) {
return row.name;
},
Formatmatch:function (row, I, max) {
return row.name + "";
},
Formatresult:function (Row) {
return row.name;
}
});
AutoComplete. ASHX return Joson value
Copy Code code as follows:
String querystr = context. request.querystring["Q"];
Context. Response.ContentType = "Text/plain";
Context. Response.Cache.SetNoStore ();
String jsponstring = "[";
string where = string. Format ("(Select dbo.[ F_GETPY] (platname)) like '%{0}% ' or platname like '%{0}% ', COMMON.COMMON.TOSQL (QUERYSTR));
DataTable dt = new Models.plat (). Getdatatable (where,10);
if (dt. Rows.Count > 0)
{
for (int i = 0; i < dt. Rows.Count; i++)
{
Jsponstring + = "{id:\" "+ dt. rows[i]["Platid"]. ToString () + "\", name:\ "" + dt. rows[i]["Platname"]. ToString () + "\"}, ";
}
}
jsponstring = Jsponstring.trim (new char[] {', '});
Jsponstring + = "]";
Context. Response.Write (jsponstring);
Context. Response.End ();