var tem = new Array();
$(function () {
$("#txtClientName").autocomplete({
source: function (request, response) {
$.ajax({
url: "url",
type: "POST",
dataType: "json",
data: { searchText: request.term, maxResults: 10 },
success: function (data) {
if (data.toString() != "No Record Found") {
var i = 0;
response($.map(data, function (item) {
// $('#txtName').val(item.strUserName);
tem[i] = item.Text;
i++;
return { label: item.Text, id: item.Value }
}))
}
}
})
},
select: function (event, ui) {
//alert(ui.item ? (ui.item.label +"You picked '" + ui.item.label + "' with an ID of " + ui.item.id): "Nothing selected, input was " + this.value);
$('#txtClientName').val(ui.item.label);
}
});
});
on controller:-
public JsonResult getClientName(string searchText)
{
HomeModel mgrObj = new HomeModel();
SortedList lstObj = new SortedList();
//connect to data base query.and return list
return Json(slst);
}