Skip to main content

TokenBoxFor

The DevExpress ASP.NET MVC TokenBoxFor strongly-typed editor provides the ability to autocomplete values from a predefined list. An end-user can select a value from the dropdown list or type it manually.

Implementation Details

TokenBoxFor is realized by the TokenBoxExtension class. Its instance can be accessed via the ExtensionsFactory<ModelType>.TokenBoxFor<ValueType> helper method, which is used to add a TokenBoxFor extension to a view. This method’s parameter provides access to the TokenBoxFor‘s settings implemented by the TokenBoxSettings class, allowing you to fully customize the extension.

TokenBoxFor‘s client counterpart is represented by the MVCxClientTokenBox object.

Declaration

TokenBoxFor can be added to a view in the following manner.

@Html.DevExpress().TokenBoxFor(m => m.Employee, 
    settings => {
        settings.Properties.TextField = "Name";
        settings.Properties.ValueField = "Email";

        settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
        settings.Properties.IncrementalFilteringDelay = 500;
    }).BindList(ViewBag.EmployeeList).GetHtml()

The image below illustrates the results.

MVC_TokenBox_Overview

See Also