程序笔记
发布时间:2022-05-30 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了基于jquery的文本框与autocomplete结合使用(asp.net+json),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Js脚本引用
<script src="/scripts/Jquery.autocomplete/jquery.autocomplete.Js" type="text/JavaScript"></script>
样式引用
<style type="text/CSS" media="all">
@import url("/scripts/Jquery.autocomplete/CSS/jquery.autocomplete.CSS"
); </style>
Js代码
?$(document).ready(function ()
{ $("#<%=_SearchKeyGame.ClIEntID %>").autocomplete("./AJAXHandle/autoComplete.ashx?type=game",
{ @H_366_0
@minChars: 0,@H_366_0
@max: 9,
wIDth: 150,@H_366_0
@matchContains: true,
autoFill:
false,
formatItem: function (row,i,ma
X) { return row.name;
},
formatMatch: function (row,ma
X) { 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",
formatResult: function (row)
{ return row.name;
}
}
); autoComplete。ashx返回JOSON值
String queryStr = co
ntext.
request.query
String["q"];
co
ntext.Response.ContentType = "text/plain";
co
ntext.Response.Cache.SetNoStore(
); String Jspon
String = "[";
String where =
String.Format("
(SELEct dbo.[f_GetPy](plat
Name)) like '%
{0}%' or platname like '%
{0}%'",Common.Common.Tosql(queryStr)
); Datatable dt = new Model
s.Plat().GetDatatable(where,10
); if (dt.Row
s.Count > 0)
{ for (int i = 0; i < dt.Row
s.Count; i++)
{ Jspon
String += "
{ID:\"" + dt.Rows[i]["PlatID"].To
String() + "\",name:\"" + dt.Rows[i]["Platname"].To
String() + "\"},";
}
}
Jspon
String = Jspon
String.Trim(new char[]
{ ',' }
); Jspon
String += "]";
co
ntext.Response.Write(Jspon
String
); co
ntext.Response.End(
); 大佬总结
以上是大佬教程为你收集整理的基于jquery的文本框与autocomplete结合使用(asp.net+json)全部内容,希望文章能够帮你解决基于jquery的文本框与autocomplete结合使用(asp.net+json)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。