AutoComplete
AutoComplete
Overview
Features
Sample
Type in a country name
Type in a country name
Settings
Description
This sample shows the basic usage of the AutoComplete control.
When Case Sensitive Search is true, the user types are searched as case-sensitive
When BeginsWithSearch property is true, The control will search for items that begin with the given search term.
When Case Sensitive Search is true, the user types are searched as case-sensitive
When BeginsWithSearch property is true, The control will search for items that begin with the given search term.
Source
IndexController.cs
using System.Collections.Generic; using System.Web.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class AutoCompleteController : Controller { private readonly ControlOptions _optionModel = new ControlOptions { Options = new OptionDictionary { {"Case Sensitive Search",new OptionItem{ Values = new List<string> { "True", "False"}, CurrentValue = "False"}}, {"Begins With Search",new OptionItem{ Values = new List<string> { "True", "False"}, CurrentValue = "False"}} } }; public ActionResult Index (FormCollection collection) { IValueProvider data = collection; _optionModel.LoadPostData(data); ViewBag.DemoOptions = _optionModel; ViewBag.Countries = Countries.GetCountries(); return View(); } } }
Index.cshtml
@{ List<string> countries = ViewBag.Countries; ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; } @section Styles{ <style> .highlight { background-color: #ff0; color: #000; } </style> } <div> <label>@Html.Raw(Resources.AutoComplete.Index_Text2)</label> <p>@Html.Raw(Resources.AutoComplete.Index_Text0)</p> @Html.C1().AutoComplete().Bind(countries).CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)).BeginsWithSearch(Convert.ToBoolean(optionsModel.Options["Begins With Search"].CurrentValue)) </div> <div> <label>@Html.Raw(Resources.AutoComplete.Index_Text3)</label> <p>@Html.Raw(Resources.AutoComplete.Index_Text1)</p> @Html.C1().AutoComplete().Bind(countries).CssMatch("highlight").CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)).BeginsWithSearch(Convert.ToBoolean(optionsModel.Options["Begins With Search"].CurrentValue)) </div> @section Settings{ @Html.Partial("_OptionsMenu", optionsModel) } @section Description{ @Html.Raw(Resources.AutoComplete.Index_Text4) <br /> @Html.Raw(Resources.AutoComplete.CaseSensitiveSearchDescription_Text0) <br /> @Html.Raw(Resources.AutoComplete.BeginsWithSearchDescription_Text0) }
Documentation