Benny Sutton is 4 hire - just click here
ActionResult-Autocomplete-Json-Csharp
Turn a search input into an autocomplete input
Type text below...
/// <summary>
/// Autocomplete functionality for the search input
/// </<summary>
/// <param name="searchTerm">search string to find records that start with this parameter in the Name field</param>
/// <returns>10 names as JSON</returns>
public ActionResult Autocomplete(string searchTerm)
{
var model =
db.Downloads
.Where(r => r.Name.StartsWith(searchTerm))
.Take(10)
.Select(r => new
{
label = r.Name
});
return Json(model, JsonRequestBehavior.AllowGet);
}