Following is My cshtml file code:
@model AutofillSample.Models.Employee
@{
ViewBag.Title = "Autofilltest";
Layout = null;
}
@**@
$(document).ready(function () {
$("#EmployeeName").autocomplete(
{
//maxResults: 2,
source: function (request, response) {
$.ajax(
{
url: "/Home/getEmployeeName",
type: "POST",
dataType: "json",
data: { Prefix: request.term },
//scroll: true,
//scrollHeight: 1,
success: function (data) {
response($.map(data, function (item) {
return { label: item.EmployeeName, value: item.EmployeeName };
}))
}
})
},
minLength: 1,
maxResults: 2,
messages: {
noResults: "", results: ""
}
});
})
@using (@Html.BeginForm())
{
Name:
@Html.TextBoxFor(model => model.EmployeeName, new { htmlAttributes = new { @class = "form-control",@name= "searchTerm" } })
}
@if (ViewBag.autofilltest != null)
{
@ViewBag.autofilltest
}
krunal parmarPosted Jun 1, 2017, 3:58 AM
Rupesh KahanePosted Jun 1, 2017, 12:09 AM