Steps for getting started with Input controls in ASP.NET MVC applications:
The AutoComplete control is an auto-complete control that allows you to filter its item list as you type, as well as select a value directly from its drop-down list.
To use the AutoComplete control, you must minimally set the Bind property to an array of data in order to populate its item list. The AutoComplete control also offers several other properties to alter its behavior, such as the CssMatch property. The CssMatch property allows you to specify the CSS class that is used to highlight parts of the content that match your search terms.
The example below uses List of strings to populate the AutoComplete control's item list using the Bind property. To see a list of suggestions, type "ab" or "za" in the AutoComplete controls below.
The ComboBox control is very similar to the AutoComplete control, but rather than providing a list of suggestions as you type, the ComboBox will automatically complete and select the entry as you type.
Like the AutoComplete control, you must minimally set the ComboBox's Bind property to an array of data in order to populate its item list. You may also want to specify whether the ComboBox is editable via the IsEditable property. The IsEditable property determines whether or not a user can enter values that do not appear in the ComboBox's item list.
The example below uses two ComboBoxes bound to the same data source as the AutoComplete control above. The first ComboBox's isEditable property is set to false, while the second ComboBox's IsEditable property is set to true.
The InputDate control allows you to edit and select dates via a drop-down calendar, preventing you from entering an incorrect value. The InputDate's drop-down calendar was developed as a separate control and can be used be used independently from the InputDate control.
Both InputDate and Calendar, specify several properties to alter the controls' behavior. The most commonly used properties include:
The example below demonstrates how to use each of these properties.
Valid Range: 1/1/2021 12:00:00 AM to 12/31/2021 12:00:00 AM
The InputDateTime control combines the InputDate and InputTime controls, allowing you to set the date and time portions. The InputDateTime control has two drop-downs: a Calendar for picking dates, and a list for picking times.
The example also shows an InputDateTime that updates both the date and time parts.
Selected Date & Time:
The ListBox control displays a list of items and allows you to select items using your mouse and keyboard. Like the AutoComplete and ComboBox controls, you must specify the ListBox's Bind property in order to use the control.
The example below allows you to select an item within the ListBox control, and also displays the control's SelectedIndex and SelectedValue properties.
The InputNumber control allows you to edit numbers, preventing you from entering invalid data and optionally formatting the numeric value as it is edited. The InputNumber can be used without specifying any of its properties; however, you'll typically want to bind it to some data using the Value property.
In addition to the value property, the InputNumber control offers several other properties that can be used to alter its behavior, such as:
The example below demonstrates how to use all of these properties.
The InputMask control allows you to validate and format user input as it is entered, preventing invalid data. The InputMask control can be used without specifying any of its properties; however, you will typically set its Value and Mask properties. Like the other MVC input controls, the Value property specifies the value for the InputMask control. The Mask property specifies the control's mask and supports a combination of the following characters:
The examples below demonstrates how to use the Value and Mask properties with the InputMask, InputDate, and InputTime controls.
The Menu control allows you to create a simple drop-down list with clickable items. The Menu's items can be defined directly or by using the Bind property similar to the ComboBox. To specify the text displayed on the Menu, you can set the Header property.
The Menu control offers two ways to handle user selections, specifying a command on each menu item and the ItemClicked event. Unlike the ItemClicked event, commands are objects that implement two methods:
The example below demonstrates how to use both approaches.