AutoComplete
AutoComplete
Overview
Features
Sample
Type in a country name
Type in a country name
Description
This sample shows the basic usage of the AutoComplete control.
Source
IndexController.cs
using Microsoft.AspNetCore.Mvc; namespace MvcExplorer.Controllers { public partial class AutoCompleteController : Controller { public ActionResult Index() { ViewBag.Countries = Models.Countries.GetCountries(); return View(); } } }
Index.cshtml
@{ List<string> countries = ViewBag.Countries; } @section Styles{ <style> .highlight { background-color: #ff0; color: #000; } </style> } <div> <label>@Html.Raw(AutoCompleteRes.Index_Text2)</label> <p>@Html.Raw(AutoCompleteRes.Index_Text0)</p> <c1-auto-complete> <c1-items-source source-collection="@countries"> </c1-items-source> </c1-auto-complete> </div> <div> <label>@Html.Raw(AutoCompleteRes.Index_Text3)</label> <p>@Html.Raw(AutoCompleteRes.Index_Text1)</p> <c1-auto-complete css-match="highlight"> <c1-items-source source-collection="@countries"> </c1-items-source> </c1-auto-complete> </div> @section Description{ @Html.Raw(AutoCompleteRes.Index_Text4) }
Documentation