<pre>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using autocomplete.Models; namespace autocomplete.Controllers { public class HomeController : Controller { public ActionResult Index2() { return View(); } public JsonResult Employeename(string name) { Employee Emp = new Employee(); List<Employee> EmployeeList = new List<Employee>(); EmployeeList.Add(new Employee { EmployeeNames = "Anurag", EmployeeId = 11 }); EmployeeList.Add(new Employee { EmployeeNames = "Abhi", EmployeeId = 12 }); EmployeeList.Add(new Employee { EmployeeNames = "Anupama", EmployeeId = 13 }); EmployeeList.Add(new Employee { EmployeeNames = "Abhishek", EmployeeId = 114 }); EmployeeList.Add(new Employee { EmployeeNames = "Anirudh", EmployeeId = 23 }); EmployeeList.Add(new Employee { EmployeeNames = "Bibek", EmployeeId = 234 }); var a = EmployeeList.Where(x=>x.EmployeeNames.StartsWith(name)).Select(x=>x.EmployeeNames).ToList(); return Json(a, JsonRequestBehavior.AllowGet); } } }
@model IEnumerable<autocomplete.Models.Employee> <link href="~/Content/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"> $(document).ready(function () { $("#txtsearch").autocomplete ({ source: '@Url.Action("Employeename")' }); }); </script> <h2>Index1</h2> <div style="font-family:Arial"> @using (@Html.BeginForm()) { Name @Html.TextBox("SearchTerm", null, new { Id="txtsearch"}) }
Unhandled exception at line 50, column 9 in http://localhost:62008/Home/Index2 0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'autocomplete' :: ----Kindly guide me where I am doing wrong.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)