最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2012年05月30日 14:28:55   作者:  
基于jquery的文本框與autocomplete結(jié)合使用示例代碼,需要的朋友可以參考下
JS腳本引用
復(fù)制代碼 代碼如下:

<script src="/scripts/Jquery.autocomplete/jquery.autocomplete.js" type="text/javascript"></script>

樣式引用
復(fù)制代碼 代碼如下:

<style type="text/css" media="all">
@import url("/scripts/Jquery.autocomplete/css/jquery.autocomplete.css");
</style>

JS代碼
復(fù)制代碼 代碼如下:

?$(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值
復(fù)制代碼 代碼如下:

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();

相關(guān)文章

最新評論

田东县| 东乡县| 嘉兴市| 利津县| 逊克县| 荔波县| 英山县| 通渭县| 东明县| 当阳市| 奎屯市| 固镇县| 垣曲县| 禹州市| 四子王旗| 来安县| 浮山县| 鄂托克旗| 嵩明县| 黔西县| 乌兰浩特市| 黔南| 布尔津县| 锡林浩特市| 高雄市| 南华县| 磴口县| 施秉县| 乐业县| 谷城县| 乌拉特前旗| 板桥市| 盐边县| 阳谷县| 阳新县| 仙桃市| 辉县市| 潞城市| 龙陵县| 宾阳县| 平潭县|