How to Enable Autofill in ASP.NET MVC AutoComplete
27 Aug 20261 minute to read
The AutoComplete supports the autofill behavior with the help of the autofill property. To enable autofill, set the autofill property to true. Whenever you change the input value, the AutoComplete will autocomplete your data by matching the typed character. If no matches are found, the AutoComplete does not apply the inline completion.
The following sample shows how to use the autofill property with the AutoComplete.
@Html.EJS().AutoComplete("games").Autofill(true).Placeholder("Select a game").PopupHeight("200px").DataSource((IEnumerable<object>)ViewBag.data).Fields(new Syncfusion.EJ2.DropDowns.AutoCompleteFieldSettings { Value = "Name" }).Render()using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class AutoCompleteController : Controller
{
public ActionResult autofill()
{
ViewBag.data = new Countries().CountriesList();
return View();
}
}
}