[CSHTML]
@using (Html.BeginForm())
{
<div class="row">
<input type="hidden" id="Auto_hidden" name="Auto" />
@Html.EJ().AutocompleteFor(x => x.IdCar, newSyncfusion.JavaScript.Models.AutocompleteProperties()
{
DataSource = (IEnumerable<CarsList>)ViewBag.datasource,
AutocompleteFields = new AutocompleteFields() { Text = "text", Key = "uniqueKey"}
}).Width("100%").ClientSideEvents(c => c.Select("onSelect"))
</div>
[Script]
function onSelect(args) {
$("#Auto_hidden").val(args.key);
}
[Controller]
[HttpPost]
public ActionResult AutocompleteFeatures(CarVM model,string Auto)
{
int Id = Int32.Parse(Auto);
return View(model);
} |
If you need not like to pass the key value manually, we suggest you to use the DropDownList with the EnableFilterSearch to behave that will allow you to search like Autocomplete.