Hi,
I am facing problem in implementing autocomplete from database to textbox in my MVC application.
<input type="text" id="SupplierName" name="SupplierName" style="width:100px;" />
$('#SupplierName').autocomplete({
source: '@Url.Action("AutoCompleteSupplier", "Quote")'
});
public JsonResult AutoCompleteSupplier(string term)
{
var result = (from r in db.SupplierMasters
where r.SupplierName.ToLower().Contains(term.ToLower())
select new { r.SupplierName }).Distinct();
//var productNames = (from p in mhgDb.Products where p.ProductName.Contains(q) select p.ProductName).Distinct
return Json(result, JsonRequestBehavior.AllowGet);
}
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jquery")
@* @Scripts.Render("~/bundles/jqueryui")*@
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jqueryui")
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.9.2.min.js"></script>
<script src="@Url.Content("~/Scripts/jquery.autocomplete.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Scripts/jquery.autocomplete.css")" rel="stylesheet" type="text/css" />
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>
@*<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>*@
<link rel="stylesheet" href="/resources/demos/style.css">