国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

基于jquery的文本框與autocomplete結(jié)合使用(asp.net+json)

2024-05-06 14:21:52
字體:
供稿:網(wǎng)友
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", {
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返回JOSON值
代碼如下:
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();
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 通城县| 乌恰县| 土默特左旗| 酒泉市| 贵州省| 闵行区| 桐柏县| 山西省| 弋阳县| 迭部县| 江西省| 上饶县| 和平县| 玉门市| 迁西县| 康马县| 富民县| 合阳县| 屏南县| 黑河市| 托克托县| 新郑市| 佛坪县| 新田县| 张家口市| 彭泽县| 张家港市| 南郑县| 阿合奇县| 潜山县| 平安县| 元谋县| 吉木乃县| 璧山县| 永嘉县| 隆林| 铁岭县| 皮山县| 南召县| 小金县| 广丰县|