## Class TCheckBox

Description

Implements interfaces:

- IPostBackDataHandler
- IValidatable
- IDataRenderer
- ISurroundable

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
- version: $Id: TCheckBox.php 2434 2008-04-18 09:47:05Z mikl $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/WebControls/TCheckBox.php (line 43)

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

Direct descendents

Class | Description
--- | ---
TActiveCheckBox | TActiveCheckBox class.
TRadioButton | TRadioButton class

Method Summary
boolean getAutoPostBack ()
boolean getCausesValidation ()
boolean getChecked ()
string getClientClassName ()
boolean getData ()
boolean getDataChanged ()
boolean getEnableClientScript ()
TMap getInputAttributes ()
TMap getLabelAttributes ()
array getPostBackOptions ()
bool getSpanNeeded ()
string getSurroundingTagID ()
string getTagName ()
string getText ()
TTextAlign getTextAlign ()
string getValidationGroup ()
mixed getValidationPropertyValue ()
string getValue ()
string getValueAttribute ()
boolean loadPostData (string $key, array $values)
void onCheckedChanged (TEventParameter $param)
void onPreRender (mixed $param)
void raisePostDataChangedEvent ()
void render (THtmlWriter $writer)
void renderClientControlScript (mixed $writer)
void renderInputTag (THtmlWriter $writer, string $clientID, string $onclick)
void renderLabel (THtmlWriter $writer, string $clientID, string $text)
void setAutoPostBack (boolean $value)
void setCausesValidation (boolean $value)
void setChecked (boolean $value)
void setData (boolean $value)
void setEnableClientScript (boolean $value)
void setText (string $value)
void setTextAlign (TTextAlign $value)
void setValidationGroup (string $value)
void setValue (string $value)
Methods
getAutoPostBack (line 223)

- return: whether clicking on the checkbox will post the page.
- access: public

boolean getAutoPostBack ()
getCausesValidation (line 240)

- return: whether postback event triggered by this checkbox will cause input validation, default is true.
- access: public

boolean getCausesValidation ()
getChecked (line 180)

- return: whether the checkbox is checked
- access: public

boolean getChecked ()
getClientClassName (line 476)

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

This method overrides the parent implementation.

- return: the javascript class name
- access: protected

string getClientClassName ()

Redefined in descendants as:

- TActiveCheckBox::getClientClassName()
- TRadioButton::getClientClassName() : Gets the name of the javascript class responsible for performing postback for this control.
- TActiveRadioButton::getClientClassName()

getData (line 202)

Returns the value indicating whether the checkbox is checked.

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

- return: whether the checkbox is checked.
- access: public
- since: 3.1.0
- see: TCheckBox::getChecked()

boolean getData ()
getDataChanged (line 114)

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

This method is required by the IPostBackDataHandler interface.

- return: whether postback has caused the control data change. False if the page is not in postback mode.
- access: public

boolean getDataChanged ()
getEnableClientScript (line 382)

- return: whether to render javascript.
- access: public

boolean getEnableClientScript ()

Redefined in descendants as:

- TRadioButton::getEnableClientScript()

getInputAttributes (line 348)

- return: list of attributes to be rendered for the checkbox
- access: public

TMap getInputAttributes ()
getLabelAttributes (line 333)

- return: list of attributes to be rendered for label beside the checkbox
- access: public

TMap getLabelAttributes ()

Redefined in descendants as:

- TActiveCheckBox::getLabelAttributes() : Overrides parent implementation to ensure label has ID.
- TActiveRadioButton::getLabelAttributes() : Overrides parent implementation to ensure label has ID.

getPostBackOptions (line 485)

Gets the post back options for this checkbox.

- access: protected

array getPostBackOptions ()
getSpanNeeded (line 401)

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.

- return: wether this control needs a surrounding span tag
- access: protected

bool getSpanNeeded ()
getSurroundingTagID (line 273)

- return: the id of the surrounding tag or this clientID if no such tag needed
- access: public

string getSurroundingTagID ()
getTagName (line 50)

- return: tag name of the button
- access: protected

string getTagName ()

Redefinition of:

TWebControl::getTagName()
  Returns the tag name used for this control.

getText (line 131)

- return: the text caption of the checkbox
- access: public

string getText ()
getTextAlign (line 164)

- return: the alignment (Left or Right) of the text caption, defaults to TTextAlign::Right.
- access: public

TTextAlign getTextAlign ()
getValidationGroup (line 257)

- return: the group of validators which the checkbox causes validation upon postback
- access: public

string getValidationGroup ()
getValidationPropertyValue (line 123)

Returns the value of the property that needs validation.

- return: the property value to be validated
- access: public

mixed getValidationPropertyValue ()
getValue (line 148)

- return: the value of the checkbox. Defaults to empty.
- access: public

string getValue ()
getValueAttribute (line 363)

- return: the value attribute to be rendered
- access: protected

string getValueAttribute ()

Redefined in descendants as:

- TRadioButton::getValueAttribute()

loadPostData (line 62)

Loads user input data.

This method is primarly used by framework developers.

- return: whether the data of the control has been changed
- access: public

boolean loadPostData (string $key, array $values)

- string $key: the key that can be used to retrieve data from the input data collection
- array $values: the input data collection

Redefined in descendants as:

- TRadioButton::loadPostData() : Loads user input data.

onCheckedChanged (line 89)

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.

- access: public

void onCheckedChanged (TEventParameter $param)

- TEventParameter $param: event parameter to be passed to the event handlers

onPreRender (line 102)

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.

- access: public

void onPreRender (mixed $param)

- mixed $param: event parameter

Redefinition of:

TControl::onPreRender()
  This method is invoked when the control enters 'OnPreRender' stage.

raisePostDataChangedEvent (line 76)

Raises postdata changed event.

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

- access: public

void raisePostDataChangedEvent ()
render (line 284)

Renders the checkbox control.

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

- access: public

void render (THtmlWriter $writer)

- THtmlWriter $writer: the writer used for the rendering purpose

Redefinition of:

TWebControl::render()
  Renders the control.

renderClientControlScript (line 465)

Renders the client-script code.

- access: protected

void renderClientControlScript (mixed $writer)

Redefined in descendants as:

- TActiveCheckBox::renderClientControlScript() : Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.
- TRadioButton::renderClientControlScript() : Renders the client-script code.
- TActiveRadioButton::renderClientControlScript() : Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.

renderInputTag (line 427)

Renders a checkbox input element.

- access: protected

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

- THtmlWriter $writer: the writer for the rendering purpose
- string $clientID: checkbox id
- string $onclick: onclick js

Redefined in descendants as:

- TActiveCheckBox::renderInputTag() : Ensure that the ID attribute is rendered and registers the javascript code for initializing the active control.
- TRadioButton::renderInputTag() : Renders a radiobutton input element.
- TActiveRadioButton::renderInputTag() : Ensure that the ID attribute is rendered and registers the javascript code for initializing the active control.

renderLabel (line 411)

Renders a label beside the checkbox.

- access: protected

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

- THtmlWriter $writer: the writer for the rendering purpose
- string $clientID: checkbox id
- string $text: label text

Redefined in descendants as:

- TActiveCheckBox::renderLabel() : Renders a label beside the checkbox.
- TActiveRadioButton::renderLabel() : Renders a label beside the radio button.

setAutoPostBack (line 232)

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

- access: public

void setAutoPostBack (boolean $value)

- boolean $value: whether clicking on the checkbox will post the page.

setCausesValidation (line 249)

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

- access: public

void setCausesValidation (boolean $value)

- boolean $value: whether postback event trigger by this checkbox will cause input validation.

setChecked (line 189)

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

- access: public

void setChecked (boolean $value)

- boolean $value: whether the checkbox is to be checked or not.

Redefined in descendants as:

- TActiveCheckBox::setChecked() : Sets a value indicating whether the checkbox is to be checked or not.
- TActiveRadioButton::setChecked() : Checks the radio button.

setData (line 215)

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().

- access: public
- since: 3.1.0
- see: TCheckBox::setChecked()

void setData (boolean $value)

- boolean $value: whether the checkbox is to be checked

setEnableClientScript (line 390)

- access: public

void setEnableClientScript (boolean $value)

- boolean $value: whether to render javascript.

Redefined in descendants as:

- TRadioButton::setEnableClientScript()

setText (line 140)

Sets the text caption of the checkbox.

- access: public

void setText (string $value)

- string $value: the text caption to be set

Redefined in descendants as:

- TActiveCheckBox::setText() : Updates the button text on the client-side if the setEnableUpdate property is set to true.
- TActiveRadioButton::setText() : Updates the button text on the client-side if the setEnableUpdate property is set to true.

setTextAlign (line 172)

- access: public

void setTextAlign (TTextAlign $value)

- TTextAlign $value: the alignment of the text caption. Valid values include Left and Right.

setValidationGroup (line 265)

- access: public

void setValidationGroup (string $value)

- string $value: the group of validators which the checkbox causes validation upon postback

setValue (line 156)

- access: public

void setValue (string $value)

- string $value: the value of the checkbox

#### Inherited 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()

Inherited From TControl

> TControl::__construct()
> 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()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

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()

Class Constants

#### Inherited Constants

Inherited from TControl

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

Documentation generated on Mon, 21 Apr 2008 11:32:58 -0400 by phpDocumentor 1.3.0RC4