## Class TButton

Description

Implements interfaces:

- IPostBackEventHandler
- IButtonControl
- IDataRenderer

TButton class

TButton creates a click button on the page. It is mainly used to submit data to a page.

TButton raises two server-side events, OnClick and OnCommand, when it is clicked on the client-side. The difference between these two events is that the event OnCommand is bubbled up to the button's ancestor controls. And within the event parameter for OnCommand contains the reference to the CommandName and CommandParameter property values that are set for the button object. This allows you to create multiple TButton components on a Web page and programmatically determine which one is clicked with what parameter.

Clicking on button can also trigger form validation, if CausesValidation is true. The validation may be restricted within a certain group of validator controls by setting ValidationGroup property. If validation is successful, the data will be post back to the same page.

TButton displays the Text property as the button caption.

TButton can be one of three ButtonType: Submit, Button and Reset. By default, it is a Submit button and the form submission uses the browser's default submission capability. If it is Button or Reset, postback may occur if one of the following conditions is met:

- an event handler is attached to OnClick event;
- an event handler is attached to OnCommand event;
- the button is in a non-empty validation group.

In addition, clicking on a Reset button will clear up all input fields if the button does not cause a postback.

- since: 3.0
- version: $Id: TButton.php 2541 2008-10-21 15:05:13Z qiang.xue $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/WebControls/TButton.php (line 50)

    TComponent
       |
       --TApplicationComponent
          |
          --TControl
             |
             --TWebControl
                |
                --TButton

Direct descendents

Class | Description
--- | ---
TActiveButton | TActiveButton is the active control counter part to TButton.

Method Summary
void addAttributesToRender (THtmlWriter $writer)
boolean canCauseValidation ()
TButtonType getButtonType ()
boolean getCausesValidation ()
string getClientClassName ()
string getCommandName ()
string getCommandParameter ()
string getData ()
boolean getEnableClientScript ()
boolean getIsDefaultButton ()
array getPostBackOptions ()
string getTagName ()
string getText ()
string getValidationGroup ()
boolean needPostBackScript ()
void onClick (TEventParameter $param)
void onCommand (TCommandEventParameter $param)
void raisePostBackEvent (TEventParameter $param)
void renderClientControlScript (mixed $writer)
void renderContents (THtmlWriter $writer)
void setButtonType (TButtonType $value)
void setCausesValidation (boolean $value)
void setCommandName (string $value)
void setCommandParameter (string $value)
void setData (string $value)
void setEnableClientScript (boolean $value)
void setIsDefaultButton (boolean $value)
void setText (string $value)
void setValidationGroup (string $value)
Methods
addAttributesToRender (line 81)

Adds attribute name-value pairs to renderer.

This overrides the parent implementation with additional button specific attributes.

- access: protected

void addAttributesToRender (THtmlWriter $writer)

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

Redefinition of:

TWebControl::addAttributesToRender()
  Adds attribute name-value pairs to renderer.

Redefined in descendants as:

- TActiveButton::addAttributesToRender() : Ensure that the ID attribute is rendered and registers the javascript code for initializing the active control.

canCauseValidation (line 122)

- return: whether to perform validation if the button is clicked
- access: protected

boolean canCauseValidation ()
getButtonType (line 334)

- return: the type of the button. Defaults to TButtonType::Submit.
- access: public

TButtonType getButtonType ()
getCausesValidation (line 270)

- return: whether postback event trigger by this button will cause input validation, default is true
- access: public

boolean getCausesValidation ()
getClientClassName (line 114)

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:

- TActiveButton::getClientClassName()

getCommandName (line 286)

- return: the command name associated with the OnCommand event.
- access: public

string getCommandName ()
getCommandParameter (line 302)

- return: the parameter associated with the OnCommand event
- access: public

string getCommandParameter ()
getData (line 249)

Returns the caption of the button.

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

- return: caption of the button.
- access: public
- since: 3.1.0
- see: TButton::getText()

string getData ()
getEnableClientScript (line 63)

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

boolean getEnableClientScript ()
getIsDefaultButton (line 144)

- return: true if this button is registered as a default button for a panel.
- access: public

boolean getIsDefaultButton ()
getPostBackOptions (line 164)

Returns postback specifications for the button.

This method is used by framework and control developers.

- return: parameters about how the button defines its postback behavior.
- access: protected

array getPostBackOptions ()
getTagName (line 55)

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

string getTagName ()

Redefinition of:

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

getText (line 228)

- return: caption of the button
- access: public

string getText ()
getValidationGroup (line 318)

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

string getValidationGroup ()
needPostBackScript (line 152)

- return: whether the button needs javascript to do postback
- access: protected

boolean needPostBackScript ()
onClick (line 190)

This method is invoked when the button is clicked.

The method raises 'OnClick' event to fire up the event handlers. If you override this method, be sure to call the parent implementation so that the event handler can be invoked.

- access: public

void onClick (TEventParameter $param)

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

onCommand (line 202)

This method is invoked when the button is clicked.

The method raises 'OnCommand' event to fire up the event handlers. If you override this method, be sure to call the parent implementation so that the event handlers can be invoked.

- access: public

void onCommand (TCommandEventParameter $param)

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

raisePostBackEvent (line 217)

Raises the postback event.

This method is required by IPostBackEventHandler interface. If CausesValidation is true, it will invoke the page's TPage::validate method first. It will raise OnClick and OnCommand events. This method is mainly used by framework and control developers.

- access: public

void raisePostBackEvent (TEventParameter $param)

- TEventParameter $param: the event parameter

renderClientControlScript (line 103)

Renders the client-script code.

- access: protected

void renderClientControlScript (mixed $writer)

Redefined in descendants as:

- TActiveButton::renderClientControlScript() : Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.

renderContents (line 179)

Renders the body content enclosed between the control tag.

This overrides the parent implementation with nothing to be rendered.

- access: public

void renderContents (THtmlWriter $writer)

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

Redefinition of:

TWebControl::renderContents()
  Renders the body content enclosed between the control tag.

setButtonType (line 342)

- access: public

void setButtonType (TButtonType $value)

- TButtonType $value: the type of the button.

setCausesValidation (line 278)

- access: public

void setCausesValidation (boolean $value)

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

setCommandName (line 294)

- access: public

void setCommandName (string $value)

- string $value: the command name associated with the OnCommand event.

setCommandParameter (line 310)

- access: public

void setCommandParameter (string $value)

- string $value: the parameter associated with the OnCommand event.

setData (line 262)

Sets the caption of the button.

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

- access: public
- since: 3.1.0
- see: TButton::setText()

void setData (string $value)

- string $value: caption of the button

setEnableClientScript (line 71)

- access: public

void setEnableClientScript (boolean $value)

- boolean $value: whether to render javascript.

setIsDefaultButton (line 136)

- access: public

void setIsDefaultButton (boolean $value)

- boolean $value: set by a panel to register this button as the default button for the panel.

setText (line 236)

- access: public

void setText (string $value)

- string $value: caption of the button

Redefined in descendants as:

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

setValidationGroup (line 326)

- access: public

void setValidationGroup (string $value)

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

#### 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 Sun, 11 Jan 2009 20:18:30 -0500 by phpDocumentor 1.3.0RC4