krunal parmar

krunal parmar

  • NA
  • 14
  • 2.2k

Scrollable Autocomplete textbox in C# MVC

May 31 2017 8:13 AM
I am not able to make a scrollable autocomplete textbox.Can anyone help me?. I've tried all the possible solutions but I m stuck plz help me.

Following is My cshtml file code: 
 
 
@model AutofillSample.Models.Employee
@{
ViewBag.Title = "Autofilltest";
Layout = null;
}
<link href="~/content/jquery-ui.min.css" rel="stylesheet" />
@*<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">*@
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">
$(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: ""
}
});
})
</script>
@using (@Html.BeginForm())
{
<b>Name: </b>
@Html.TextBoxFor(model => model.EmployeeName, new { htmlAttributes = new { @class = "form-control",@name= "searchTerm" } })
<input type="submit" value="Search">
}
@if (ViewBag.autofilltest != null)
{
<div>@ViewBag.autofilltest</div>
}




Answers (2)