Back to Devexpress

CheckBox

aspnetmvc-8982-components-data-editors-extensions-checkbox.md

latest2.1 KB
Original Source

CheckBox

  • Dec 17, 2020
  • 3 minutes to read

CheckBox represents a check editor that allows the end user to make a selection, such as true/false or yes/no.

Implementation Details

CheckBox is realized by the CheckBoxExtension class. Its instance can be accessed via the ExtensionsFactory.CheckBox helper method, which is used to add a CheckBox extension to a view. This method’s parameter provides access to the CheckBox ‘s settings implemented by the CheckBoxSettings class, allowing you to fully customize the extension.

CheckBox ‘s client counterpart is represented by the ASPxClientCheckBox object.

Declaration

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

razor
@Html.DevExpress().CheckBox(settings => {
    settings.Name = "checkBox1";
    settings.Checked = true;
    settings.Text = "Show button";
    settings.Properties.ClientSideEvents.CheckedChanged = "function (s, e){ myButton.SetVisible(!myButton.GetVisible());}";
}).GetHtml()

@Html.DevExpress().Button(settings => {
    settings.Name = "myButton";
    settings.EnableClientSideAPI = true;
}).GetHtml()

Note

The Partial View should contain only the extension’s code.

The code result is demonstrated in the image below.

Main Features

The CheckBox extension is a check editor that allows end-users to select yes/no or true/false conditions. A check state can be switched by clicking the editor with the mouse or by pressing the SPACE key when the editor has focus.

The CheckBox offers the following features.

  • Three State Support

  • Native Rendering

  • Appearance Customization

  • Built-in Validation

  • Full-Featured Client-Side API