Autocomplete in ASP.NET MVC3自动检索并填充输入框
来源:互联网 发布:企业网站结构优化 编辑:程序博客网 时间:2024/06/03 22:47
1、单一产品情况下使用:
public ActionResult GetStockList(){ var item = _db.Stocks.ToList().Select(s =>s.Product.CodePro); return Json(item, JsonRequestBehavior.AllowGet);}
<script type="text/javascript"> $(function () { var url = "/Mana/BillOfLading/GetStockList"; $.getJSON(url, null, function (myData) { var availableTags = myData; $("#stockid").autocomplete({ source: availableTags }); }); }); </script><div class="ui-widget"> <label for="stockid">Tags: </label> <input id="stockid" /></div>
2、多组返回值的情况下:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /><script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script><script type="text/javascript"> $(function () { $("#SearchString").autocomplete({ source: "/Student/AutocompleteSuggestions", minLength: 1, select: function (event, ui) { if (ui.item) { $("#SearchString").val(ui.item.value); $("#txtlabel").text(ui.item.label); } } }); });</script>
<div class="ui-widget"> <label id="txtlabel" style="color:Red"></label><br /> Find by name: @Html.TextBox("SearchString") <input type="submit" value="Search" /> </div>
public ActionResult AutocompleteSuggestions(string term){ var suggestions = db.Students.Select(s => new { label = s.LastName+"|"+s.FirstMidName, value = s.StudentID}).Where(b=>b.label.ToLower().StartsWith(term.ToLower())); return Json(suggestions, JsonRequestBehavior.AllowGet);}
0 0
- Autocomplete in ASP.NET MVC3自动检索并填充输入框
- 自动填充输入框 Asp .Net Mvc
- ASP.NET MVC3 jQuery Autocomplete
- 在asp.net mvc3 中使用autocomplete jquery ui
- AJAX基本应用之:根据输入内容自动填充下拉框。(ASP.NET版)[转]
- input自动填充-Autocomplete
- input自动填充-Autocomplete
- autocomplete 自动填充
- autocomplete自动填充
- jQuery UI Autocomplete 类似百度、谷歌输入框的自动填充文本域
- jQuery UI Autocomplete 类似百度、谷歌输入框的自动填充文本域
- ASP.NET MVC3 上传头像图片并截图
- Error handling in ASP.NET MVC3
- AJAX.NET实现根据输入内容自动填充下拉框
- 自动填充插件Autocomplete demo
- autocomplete.js 输入框,自动提示
- input文本输入框自动提示-autocomplete
- jquery autocomplete 类似百度搜索框 自动填充内容
- HiLo
- 在BeagleBone Black上构建Linux 0.1
- poj2485 Kruskal算法+并查集 922MS险过
- average
- Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly Detection&Recommende
- Autocomplete in ASP.NET MVC3自动检索并填充输入框
- 说说Oracle监听器(一)
- HTML5本地存储之Web Storage篇
- C 语言程序设计实践 5.1 得分
- Java程序的回调的实现
- 8.5 第八章小结
- 单链表应用
- ios8iphone6plus 设计规范及适配尺寸 将附PSD【懒人版】
- Js获取当前日期时间及其它操作