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 MvcExplorer.Models; using System.Collections.Generic; using System.Web.Mvc; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { private readonly ControlOptions _optionModel = new ControlOptions { Options = new OptionDictionary { {"Case Sensitive 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(); ViewBag.Cities = Cities.GetCities(); return View(); } } }
Index.cshtml
@{ List<string> countries = ViewBag.Countries; List<string> cities = ViewBag.Cities; ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; } <div> <label>@Html.Raw(Resources.ComboBox.Index_NonEditable)</label> @(Html.C1().ComboBox().Bind(countries).SelectedIndex(0).IsEditable(false) .CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue))) </div> <div> <label>@Html.Raw(Resources.ComboBox.Index_Editable)</label> @(Html.C1().ComboBox().Bind(cities).SelectedIndex(0).IsEditable(true) .CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue))) </div> @section Settings{ @Html.Partial("_OptionsMenu", optionsModel) } @section Description{ @Html.Raw(Resources.ComboBox.Index_Text0) <br /> @Html.Raw(Resources.ComboBox.CaseSensitiveSearchDescription_Text0) }
Documentation