ComboBox
Overview
Features
Sample
Settings
Description
This sample shows the basic usage of the ComboBox control.
When Case Sensitive Search is true, the user types are searched as case-sensitive
When Case Sensitive Search is true, the user types are searched as case-sensitive
Source
IndexController.cs
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; using System.Collections.Generic; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { private readonly ControlOptions _options = new ControlOptions { Options = new OptionDictionary { {"Case Sensitive Search",new OptionItem{ Values = new List<string> { "True", "False"}, CurrentValue = "False"}} } }; private readonly C1NWindEntities _db; public ComboBoxController(C1NWindEntities db) { _db = db; } public ActionResult Index(IFormCollection collection) { _options.LoadPostData(collection); ViewBag.DemoOptions = _options; ViewBag.Countries = Countries.GetCountries(); ViewBag.Cities = Cities.GetCities(); return View(); } } }
Index.cshtml
@{ ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; List<string> countries = ViewBag.Countries; List<string> cities = ViewBag.Cities; } <div> <label>@Html.Raw(ComboBoxRes.Index_NonEditable)</label> <c1-combo-box selected-index="0" is-editable="false" max-drop-down-width="55" case-sensitive-search="@Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)"> <c1-items-source source-collection="@countries"></c1-items-source> </c1-combo-box> </div> <div> <label>@Html.Raw(ComboBoxRes.Index_Editable)</label> <c1-combo-box selected-index="0" is-editable="true" case-sensitive-search="@Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)"> <c1-items-source source-collection="@cities"></c1-items-source> </c1-combo-box> </div> @section Settings{ @await Html.PartialAsync("_OptionsMenu", optionsModel) } @section Description{ @Html.Raw(ComboBoxRes.Index_Text0) <br /> @Html.Raw(ComboBoxRes.CaseSensitiveSearchDescription_Text0) }
Documentation