Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <link href="~/Content/css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" />
- <script src="~/Scripts/jquery-1.10.2.js"></script>
- <script src="~/Scripts/jquery-ui-1.10.4.custom.min.js"></script>
- <script type="text/javascript">
- $(function () {
- $("#txtSearch").autocomplete({
- source: '@Url.Action("GetTitle")'
- });
- });
- [HttpPost]
- public ActionResult Index(string Search)
- {
- List<Legislation> objLegis = new List<Legislation>();
- if (!string.IsNullOrEmpty(Search))
- {
- objLegis = db.Legislations.Where(x => x.TITLE.StartsWith(Search) || x.NUMBER.StartsWith(Search)).ToList().Take(10).ToList<Legislation>();
- ModelState.Clear();
- }
- else
- {
- objLegis = db.Legislations.ToList().Take(10).ToList<Legislation>();
- }
- return View(objLegis);
- }
- public JsonResult GetTitle(string term)
- {
- elawdb_liveEntities db = new elawdb_liveEntities();
- List<string> objLegis;
- objLegis = db.Legislations.Where(x => x.TITLE.StartsWith(term))
- .Select(y => y.TITLE).ToList();
- return Json(objLegis, JsonRequestBehavior.AllowGet);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement