- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml
Classes:
IDataSource
IItemDataRenderer
IRepeatInfoUser
TActiveFileUpload
TBaseDataList
TBaseValidator
TBoundColumn
TBulletedList
TBulletedListDisplayMode
TBulletedListEventParameter
TBulletStyle
TButton
TButtonColumn
TButtonColumnType
TButtonType
TCaptcha
TCaptchaValidator
TCheckBox
TCheckBoxColumn
TCheckBoxList
TCircleHotSpot
TClientScript
TClientScriptLoader
TClientSideValidationSummaryOptions
TColorPicker
TColorPickerClientSide
TColorPickerMode
TCompareValidator
TCompleteWizardStep
TConditional
TContent
TContentDirection
TContentPlaceHolder
TCustomValidator
TDataBoundControl
TDataGrid
TDataGridColumn
TDataGridColumnCollection
TDataGridCommandEventParameter
TDataGridItem
TDataGridItemCollection
TDataGridItemEventParameter
TDataGridItemRenderer
TDataGridPageChangedEventParameter
TDataGridPager
TDataGridPagerButtonType
TDataGridPagerEventParameter
TDataGridPagerMode
TDataGridPagerPosition
TDataGridPagerStyle
TDataGridSortCommandEventParameter
TDataList
TDataListCommandEventParameter
TDataListItem
TDataListItemCollection
TDataListItemEventParameter
TDataListItemRenderer
TDataRenderer
TDataSourceControl
TDataSourceSelectParameters
TDataSourceView
TDataTypeValidator
TDatePicker
TDatePickerClientScript
TDatePickerInputMode
TDatePickerMode
TDatePickerPositionMode
TDisplayStyle
TDraggable
TDropContainer
TDropDownList
TDropDownListColumn
TEditCommandColumn
TEmailAddressValidator
TExpression
TFileUpload
TFont
THiddenField
THorizontalAlign
THotSpot
THotSpotCollection
THotSpotMode
THtmlArea
THtmlElement
THyperLink
THyperLinkColumn
TImage
TImageButton
TImageClickEventParameter
TImageMap
TImageMapEventParameter
TInlineFrame
TInlineFrameAlign
TInlineFrameScrollBars
TItemDataRenderer
TJavascriptLogger
TKeyboard
TLabel
TLinkButton
TListBox
TListControl
TListControlValidator
TListItem
TListItemCollection
TListItemType
TListSelectionMode
TLiteral
TLiteralColumn
TMarkdown
TMetaTag
TMetaTagCollection
TMultiView
TOutputCache
TOutputCacheCalculateKeyEventParameter
TOutputCacheCheckDependencyEventParameter
TPager
TPagerButtonType
TPagerMode
TPagerPageChangedEventParameter
TPanel
TPanelStyle
TPlaceHolder
TPolygonHotSpot
TRadioButton
TRadioButtonList
TRangeValidationDataType
TRangeValidator
TRatingList
TReadOnlyDataSource
TReadOnlyDataSourceView
TRectangleHotSpot
TRegularExpressionValidator
TRepeatDirection
TRepeater
TRepeaterCommandEventParameter
TRepeaterItem
TRepeaterItemCollection
TRepeaterItemEventParameter
TRepeaterItemRenderer
TRepeatInfo
TRepeatLayout
TRequiredFieldValidator
TSafeHtml
TScrollBars
TServerValidateEventParameter
TSlider
TSliderClientScript
TSliderDirection
TStatements
TStyle
TStyleSheet
TTable
TTableCaptionAlign
TTableCell
TTableCellCollection
TTableFooterRow
TTableGridLines
TTableHeaderCell
TTableHeaderRow
TTableHeaderScope
TTableItemStyle
TTableRow
TTableRowCollection
TTableRowSection
TTableStyle
TTabPanel
TTabView
TTabViewCollection
TTemplateColumn
TTemplatedWizardStep
TTextAlign
TTextBox
TTextBoxAutoCompleteType
TTextBoxMode
TTextHighlighter
TTextHighlighterLineNumberStyle
TValidationCompareOperator
TValidationDataType
TValidationSummary
TValidationSummaryDisplayMode
TValidationSummaryDisplayStyle
TValidatorClientSide
TValidatorDisplayStyle
TVerticalAlign
TView
TViewCollection
TWebControl
TWebControlAdapter
TWizard
TWizardFinishNavigationTemplate
TWizardNavigationButtonStyle
TWizardNavigationButtonType
TWizardNavigationContainer
TWizardNavigationEventParameter
TWizardNavigationTemplate
TWizardSideBarListItemTemplate
TWizardSideBarTemplate
TWizardStartNavigationTemplate
TWizardStep
TWizardStepCollection
TWizardStepNavigationTemplate
TWizardStepType
TXmlTransform

Keyword

# Class TCheckBox

    TComponent
       |
       --TApplicationComponent
          |
          --TControl
             |
             --TWebControl
                |
                --TCheckBox

#### Direct Known Sub-classes:

TActiveCheckBox , TRadioButton

TCheckBox class

TCheckBox displays a check box on the page. You can specify the caption to display beside the check box by setting the Text property. The caption can appear either on the right or left of the check box, which is determined by the TextAlign property.

To determine whether the TCheckBox component is checked, test the Checked property. The OnCheckedChanged event is raised when the Checked state of the TCheckBox component changes between posts to the server. You can provide an event handler for the OnCheckedChanged event to to programmatically control the actions performed when the state of the TCheckBox component changes between posts to the server.

If AutoPostBack is set true, changing the check box state will cause postback action. And if CausesValidation is true, validation will also be processed, which can be further restricted within a ValidationGroup.

Note, Text is rendered as is. Make sure it does not contain unwanted characters that may bring security vulnerabilities.

Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Constants Inherited From TControl

AUTOMATIC_ID_PREFIX, CLIENT_ID_SEPARATOR, CS_CHILD_INITIALIZED, CS_CONSTRUCTED, CS_INITIALIZED, CS_LOADED, CS_PRERENDERED, CS_STATE_LOADED, ID_FORMAT, ID_SEPARATOR, IS_CHILD_CREATED, IS_CREATING_CHILD, IS_DISABLE_THEMING, IS_DISABLE_VIEWSTATE, IS_ID_SET, IS_SKIN_APPLIED, IS_STYLESHEET_APPLIED, RF_ADAPTER, RF_AUTO_BINDINGS, RF_CHILD_STATE, RF_CONTROLS, RF_CONTROLSTATE, RF_DATA_BINDINGS, RF_EVENTS, RF_NAMED_CONTROLS, RF_NAMED_CONTROLS_ID, RF_NAMED_OBJECTS, RF_SKIN_ID,

Method Summary
boolean | getAutoPostBack ()
boolean | getCausesValidation ()
boolean | getChecked ()
protected string | getClientClassName () Gets the name of the javascript class responsible for performing postback for this control.
boolean | getData () Returns the value indicating whether the checkbox is checked.
boolean | getDataChanged () Returns a value indicating whether postback has caused the control data change.
boolean | getEnableClientScript ()
TMap | getInputAttributes ()
bool | getIsValid () Returns true if this control validated successfully.
TMap | getLabelAttributes ()
protected array | getPostBackOptions () Gets the post back options for this checkbox.
protected bool | getSpanNeeded () Check if we need a span tag to surround this control. The span tag will be created if the Text property is set for this control.
string | getSurroundingTagID ()
protected string | getTagName ()
string | getText ()
TTextAlign | getTextAlign ()
string | getValidationGroup ()
mixed | getValidationPropertyValue () Returns the value of the property that needs validation.
string | getValue ()
protected string | getValueAttribute ()
boolean | loadPostData ( string $key, array $values) Loads user input data.
void | onCheckedChanged ( TEventParameter $param) Raises OnCheckedChanged event when getChecked changes value during postback.
void | onPreRender ( mixed $param) Registers the checkbox to receive postback data during postback.
void | raisePostDataChangedEvent () Raises postdata changed event.
void | render ( THtmlWriter $writer) Renders the checkbox control.
protected void | renderClientControlScript ( mixed $writer) Renders the client-script code.
protected void | renderInputTag ( THtmlWriter $writer, string $clientID, string $onclick) Renders a checkbox input element.
protected void | renderLabel ( THtmlWriter $writer, string $clientID, string $text) Renders a label beside the checkbox.
void | setAutoPostBack ( boolean $value) Sets a value indicating whether clicking on the checkbox will post the page.
void | setCausesValidation ( boolean $value) Sets the value indicating whether postback event trigger by this checkbox will cause input validation.
void | setChecked ( boolean $value) Sets a value indicating whether the checkbox is to be checked or not.
void | setData ( boolean $value) Sets the value indicating whether the checkbox is to be checked or not.
void | setEnableClientScript ( boolean $value)
void | setIsValid ( bool $value)
void | setText ( string $value) Sets the text caption of the checkbox.
void | setTextAlign ( TTextAlign $value)
void | setValidationGroup ( string $value)
void | setValue ( string $value)

Methods Inherited From TWebControl

TWebControl::addAttributesToRender(), TWebControl::clearStyle(), TWebControl::copyBaseAttributes(), TWebControl::createStyle(), TWebControl::getAccessKey(), TWebControl::getBackColor(), TWebControl::getBorderColor(), TWebControl::getBorderStyle(), TWebControl::getBorderWidth(), TWebControl::getCssClass(), TWebControl::getDisplay(), TWebControl::getFont(), TWebControl::getForeColor(), TWebControl::getHasStyle(), TWebControl::getHeight(), TWebControl::getStyle(), TWebControl::getTabIndex(), TWebControl::getTagName(), TWebControl::getToolTip(), TWebControl::getWidth(), TWebControl::render(), TWebControl::renderBeginTag(), TWebControl::renderContents(), TWebControl::renderEndTag(), TWebControl::setAccessKey(), TWebControl::setBackColor(), TWebControl::setBorderColor(), TWebControl::setBorderStyle(), TWebControl::setBorderWidth(), TWebControl::setCssClass(), TWebControl::setDisplay(), TWebControl::setForeColor(), TWebControl::setHeight(), TWebControl::setStyle(), TWebControl::setTabIndex(), TWebControl::setToolTip(), TWebControl::setWidth()

Methods Inherited From TControl

TControl::addedControl(), TControl::addParsedObject(), TControl::addToPostDataLoader(), TControl::applyStyleSheetSkin(), TControl::autoBindProperty(), TControl::autoDataBindProperties(), TControl::bindProperty(), TControl::broadcastEvent(), TControl::bubbleEvent(), TControl::clearChildState(), TControl::clearControlState(), TControl::clearNamingContainer(), TControl::clearViewState(), TControl::convertUniqueIdToClientId(), TControl::createChildControls(), TControl::createControlCollection(), TControl::dataBind(), TControl::dataBindChildren(), TControl::dataBindProperties(), TControl::ensureChildControls(), TControl::findControl(), TControl::findControlsByID(), TControl::findControlsByType(), TControl::focus(), TControl::getAdapter(), TControl::getAllowChildControls(), TControl::getAttribute(), TControl::getAttributes(), TControl::getChildControlsCreated(), TControl::getClientID(), TControl::getControls(), TControl::getControlStage(), TControl::getControlState(), TControl::getCustomData(), TControl::getEnabled(), TControl::getEnableTheming(), TControl::getEnableViewState(), TControl::getHasAdapter(), TControl::getHasAttributes(), TControl::getHasChildInitialized(), TControl::getHasControls(), TControl::getHasInitialized(), TControl::getHasLoaded(), TControl::getHasLoadedPostData(), TControl::getHasPreRendered(), TControl::getID(), TControl::getNamingContainer(), TControl::getPage(), TControl::getParent(), TControl::getRegisteredObject(), TControl::getSkinID(), TControl::getSourceTemplateControl(), TControl::getTemplateControl(), TControl::getUniqueID(), TControl::getViewState(), TControl::getVisible(), TControl::hasAttribute(), TControl::initRecursive(), TControl::isDescendentOf(), TControl::isObjectRegistered(), TControl::loadRecursive(), TControl::loadState(), TControl::loadStateRecursive(), TControl::onDataBinding(), TControl::onInit(), TControl::onLoad(), TControl::onPreRender(), TControl::onUnload(), TControl::preRenderRecursive(), TControl::raiseBubbleEvent(), TControl::registerObject(), TControl::removeAttribute(), TControl::removedControl(), TControl::render(), TControl::renderChildren(), TControl::renderControl(), TControl::saveState(), TControl::saveStateRecursive(), TControl::setAdapter(), TControl::setAttribute(), TControl::setChildControlsCreated(), TControl::setControlStage(), TControl::setControlState(), TControl::setCustomData(), TControl::setEnabled(), TControl::setEnableTheming(), TControl::setEnableViewState(), TControl::setID(), TControl::setPage(), TControl::setSkinID(), TControl::setTemplateControl(), TControl::setViewState(), TControl::setVisible(), TControl::trackViewState(), TControl::traverseChildControls(), TControl::unbindProperty(), TControl::unloadRecursive(), TControl::unregisterObject(), TControl::__get()

Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()

Methods Inherited From TComponent

TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constant Summary

Method Details

## getAutoPostBack

public boolean getAutoPostBack | ()

Output
boolean | whether clicking on the checkbox will post the page.
Exception

## getCausesValidation

public boolean getCausesValidation | ()

Output
boolean | whether postback event triggered by this checkbox will cause input validation, default is true.
Exception

## getChecked

public boolean getChecked | ()

Output
boolean | whether the checkbox is checked
Exception

## getClientClassName

protected string getClientClassName | ()

Gets the name of the javascript class responsible for performing postback for this control.

This method overrides the parent implementation.

Output
string | the javascript class name
Exception

## getData

public boolean getData | ()

Returns the value indicating whether the checkbox is checked.

This method is required by IDataRenderer. It is the same as getChecked().

Output
boolean | whether the checkbox is checked.
Exception

## getDataChanged

public boolean getDataChanged | ()

Returns a value indicating whether postback has caused the control data change.

This method is required by the IPostBackDataHandler interface.

Output
boolean | whether postback has caused the control data change. False if the page is not in postback mode.
Exception

## getEnableClientScript

public boolean getEnableClientScript | ()

Output
boolean | whether to render javascript.
Exception

## getInputAttributes

public TMap getInputAttributes | ()

Output
TMap | list of attributes to be rendered for the checkbox
Exception

## getIsValid

public bool getIsValid | ()

Returns true if this control validated successfully.

Defaults to true.

Output
bool | wether this control validated successfully.
Exception

## getLabelAttributes

public TMap getLabelAttributes | ()

Output
TMap | list of attributes to be rendered for label beside the checkbox
Exception

## getPostBackOptions

protected array getPostBackOptions | ()

Gets the post back options for this checkbox.

Output
Exception

## getSpanNeeded

protected bool getSpanNeeded | ()

Check if we need a span tag to surround this control. The span tag will be created if the Text property is set for this control.

Output
bool | wether this control needs a surrounding span tag
Exception

## getSurroundingTagID

public string getSurroundingTagID | ()

Output
string | the id of the surrounding tag or this clientID if no such tag needed
Exception

## getTagName

protected string getTagName | ()

Output
string | tag name of the button
Exception

## getText

public string getText | ()

Output
string | the text caption of the checkbox
Exception

## getTextAlign

public TTextAlign getTextAlign | ()

Output
TTextAlign | the alignment (Left or Right) of the text caption, defaults to TTextAlign::Right.
Exception

## getValidationGroup

public string getValidationGroup | ()

Output
string | the group of validators which the checkbox causes validation upon postback
Exception

## getValidationPropertyValue

public mixed getValidationPropertyValue | ()

Returns the value of the property that needs validation.

Output
mixed | the property value to be validated
Exception

## getValue

public string getValue | ()

Output
string | the value of the checkbox. Defaults to empty.
Exception

## getValueAttribute

protected string getValueAttribute | ()

Output
string | the value attribute to be rendered
Exception

## loadPostData

public boolean loadPostData | (string $key , array $values )

Loads user input data.

This method is primarly used by framework developers.

Input
string | $key | the key that can be used to retrieve data from the input data collection
array | $values | the input data collection
Output
boolean | whether the data of the control has been changed
Exception

## onCheckedChanged

public void onCheckedChanged | (TEventParameter $param )

Raises OnCheckedChanged event when getChecked changes value during postback.

If you override this method, be sure to call the parent implementation so that the event delegates can be invoked.

Input
TEventParameter | $param | event parameter to be passed to the event handlers
Output
Exception

## onPreRender

public void onPreRender | (mixed $param )

Registers the checkbox to receive postback data during postback.

This is necessary because a checkbox if unchecked, when postback, does not have direct mapping between post data and the checkbox name.

This method overrides the parent implementation and is invoked before render.

Input
mixed | $param | event parameter
Output
Exception

## raisePostDataChangedEvent

public void raisePostDataChangedEvent | ()

Raises postdata changed event.

This method raises OnCheckedChanged event. This method is primarly used by framework developers.

Output
Exception

## render

public void render | (THtmlWriter $writer )

Renders the checkbox control.

This method overrides the parent implementation by rendering a checkbox input element and a span element if needed.

Input
THtmlWriter | $writer | the writer used for the rendering purpose
Output
Exception

## renderClientControlScript

protected void renderClientControlScript | (mixed $writer )

Renders the client-script code.

Input
mixed | $writer |
Output
Exception

## renderInputTag

protected void renderInputTag | (THtmlWriter $writer , string $clientID , string $onclick )

Renders a checkbox input element.

Input
THtmlWriter | $writer | the writer for the rendering purpose
string | $clientID | checkbox id
string | $onclick | onclick js
Output
Exception

## renderLabel

protected void renderLabel | (THtmlWriter $writer , string $clientID , string $text )

Renders a label beside the checkbox.

Input
THtmlWriter | $writer | the writer for the rendering purpose
string | $clientID | checkbox id
string | $text | label text
Output
Exception

## setAutoPostBack

public void setAutoPostBack | (boolean $value )

Sets a value indicating whether clicking on the checkbox will post the page.

Input
boolean | $value | whether clicking on the checkbox will post the page.
Output
Exception

## setCausesValidation

public void setCausesValidation | (boolean $value )

Sets the value indicating whether postback event trigger by this checkbox will cause input validation.

Input
boolean | $value | whether postback event trigger by this checkbox will cause input validation.
Output
Exception

## setChecked

public void setChecked | (boolean $value )

Sets a value indicating whether the checkbox is to be checked or not.

Input
boolean | $value | whether the checkbox is to be checked or not.
Output
Exception

## setData

public void setData | (boolean $value )

Sets the value indicating whether the checkbox is to be checked or not.

This method is required by IDataRenderer. It is the same as setChecked().

Input
boolean | $value | whether the checkbox is to be checked
Output
Exception

## setEnableClientScript

public void setEnableClientScript | (boolean $value )

Input
boolean | $value | whether to render javascript.
Output
Exception

## setIsValid

public void setIsValid | (bool $value )

Input
bool | $value | wether this control is valid.
Output
Exception

## setText

public void setText | (string $value )

Sets the text caption of the checkbox.

Input
string | $value | the text caption to be set
Output
Exception

## setTextAlign

public void setTextAlign | (TTextAlign $value )

Input
TTextAlign | $value | the alignment of the text caption. Valid values include Left and Right.
Output
Exception

## setValidationGroup

public void setValidationGroup | (string $value )

Input
string | $value | the group of validators which the checkbox causes validation upon postback
Output
Exception

## setValue

public void setValue | (string $value )

Input
string | $value | the value of the checkbox
Output
Exception