In your view
@model Mvcsibaramhyjiya.Models.nameemail
@{
ViewBag.Title = "Autocomp";
}
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" temp_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" temp_src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" temp_src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function () {
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#email").bind("keydown", function (event) {
if (event.keyCode === $.ui.keyCode.TAB &&$(this).data("autocomplete").menu.active) {
event.preventDefault();
}
})
$("#email").autocomplete({
source: function (request, response) {
//define a function to call your Action (assuming UserController)
$.ajax({
url: '/EntryPoint/GetEmailIds', type: "GET", dataType: "json",
//query will be the param used by your action method
data: { query: request.term },
term: extractLast(request.term),
success: function (data) {
response($.map(data, function (item) {
return { label: item, value: item };
}))
}
})
},
search: function () {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
return false;
}
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
this.value = ui.item.value;
return false;
//if u want to select items in comma separate then

vishal BoradePosted Apr 9, 2014, 1:45 AM
Enter country name @Html.TextBox("Country") [HttpPost] public ActionResult Autocomplete(string term) { //var items = new[] { "Apple", "Pear", "Banana", "Pineapple", "Peach" }; PREFIX obj=new PREFIX(); var items = obj.GETPREFIX(term).Distinct().ToArray(); //var filteredItems = items.Where( // item => item.IndexOf(term, StringComparison.InvariantCultureIgnoreCase) >= 0 // ); return Json(items, JsonRequestBehavior.AllowGet); }
vishal BoradePosted Apr 9, 2014, 1:44 AM
<script type="text/javascript"> $(document).ready(function () { $("#Country").autocomplete({ source: function (request, response) { $.ajax({ url: "/Home/Autocomplete", type: "POST", dataType: "json", data: { term: request.term }, success: function (data) { alert(data) response($.map(data, function (item) { return { label: item.Country, value: item.Country }; alert(item.Country) })) } }) }, select: function (event, ui) { this.value = ui.item.value; return false; } }); })
vishal BoradePosted Apr 9, 2014, 1:44 AM
repones not working