Skip to main content
Tab

ASPxCheckBox Class

The check box control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public class ASPxCheckBox :
    ASPxEdit,
    ICheckBoxControl,
    IInternalCheckBoxOwner,
    IValueTypeHolder,
    IAllowNullOwner

Remarks

The ASPxCheckBox class is a check editor that gives the user an option, such as true/false or yes/no.

ASPxCheckbox_control.png

Create a Check Box

Design Time

The ASPxCheckBox control is available on the DX.24.1: Common Controls toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control’s settings, or paste the control’s markup in the page’s source code.

<dx:ASPxCheckBox ID="checkbox" ClientInstanceName="ClientCheckBox" runat="server" Checked="true" Text="Is In Stock?" />

Run Time

using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxCheckBox checkBox = new ASPxCheckBox();
    checkBox.ID = "checkbox";
    Page.Form.Controls.Add(checkBox);

    checkBox.ClientInstanceName = "ClientCheckBox";
    checkBox.Checked = true;
    checkBox.Text = "Is in stock?";
}

Note

DevExpress controls require that you register special modules, handlers, and options in the Web.config file. You can change this file or switch to the Design tab in the Microsoft Visual Studio IDE to automatically update the Web.config file. Note that this information is automatically registered if you use the DevExpress Template Gallery to create a project.

The state of the check box editor can be specified using the ASPxCheckBox.Checked or ASPxCheckBox.CheckState property. Checked is Boolean and can identify only checked and unchecked states. The CheckState property is more powerful. By default, it can be set to either the checked or unchecked check state. To enable the third grayed state, set the ASPxCheckBox.AllowGrayed property to true. Check box states can be associated with any type of value which is specified by the ASPxCheckBox.ValueType property. A value representing the checked state of the ASPxCheckBox is specified via the ASPxCheckBox.ValueChecked property. The ASPxCheckBox.ValueUnchecked and ASPxCheckBox.ValueGrayed properties specify the unchecked and grayed states of the check box, respectively. These property values are assigned to the editor’s ASPxEdit.Value property when the checkbox editor’s state changes.

A change to the check box editor’s state forces the ASPxCheckBox.CheckedChanged event to be fired.

A check box can be rendered using a standard HTML input element (if the ASPxCheckBox.Native property is set to true) or with fully supported customization of its appearance. In this case the appearance of a check box can be customized via the ASPxCheckBox.CheckBoxStyle property.

The ASPxCheckBox control consists of the edit region (check mark) and the text label. The editor’s text label can be defined via the ASPxCheckBox.Text property. The text label’s alignment relative to the check mark is specified via the ASPxCheckBox.TextAlign property. The ASPxCheckBox.Layout property can be used to control whether the check mark and text label are displayed using a table or flow layout.

By default, a check box edit region (check mark) is represented by an image within the ASPxCheckBox editor. It is possible to assign your own images to be displayed for different check box states. Use the ASPxCheckBox.CheckedImage, ASPxCheckBox.UncheckedImage and ASPxCheckBox.GrayedImage properties for this purpose.

Note

The client-side equivalent of this editor control is represented by the ASPxClientCheckBox object. The editor’s client-side API is enabled if the ASPxEditBase.EnableClientSideAPI property is set to true, or any client event is handled. Available client events can be accessed via the ASPxCheckBox.ClientSideEvents property.

See Also