<%= Html.TextBox("SearchString")%>
JQuery:
$(function () {
$("#SearchString").autocomplete({
source: "/JsonData/getData",
minLength: 1,
select: function (event, ui) {
if (ui.item) {
$("#SearchString").val(ui.item.value);
$("form").submit();}}});
})(jQuery);
i added jquery-ui-1.8.11.js and jquery-ui-1.8.11.min.js
json:
public JsonResult getData(string searchstring)
{
var set = (from a in CMS.StudentRegistrations select a.RollNumber);
var namelist = set.Where(n => n.ToLower().StartsWith(searchstring.ToLower()));
return Json(namelist, JsonRequestBehavior.AllowGet);
}
autocomplete textbox is not working for me. any body say me the solution . VS2010,MVC 2 only i used. Thanks in advance