|
Class TButton
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 OnClick and onCommand OnCommand, when it is clicked on the client-side. The difference
between these two events is that the event onCommand OnCommand is
bubbled up to the button's ancestor controls. And within the event parameter for
onCommand OnCommand contains the reference to the setCommandName
CommandName and setCommandParameter 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 setCausesValidation CausesValidation is true. The validation may be restricted
within a certain group of validator controls by setting setValidationGroup ValidationGroup property. If validation is successful, the
data will be post back to the same page.
TButton displays the setText Text property as the button caption.
TButton can be one of three setButtonType 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 OnClick event;
- an event handler is attached to onCommand 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.
-
TComponent
-
TApplicationComponent
-
TControl
implements
IRenderable,
IBindable
-
TWebControl
implements
IStyleable
-
TButton
implements
IPostBackEventHandler,
IButtonControl,
IDataRenderer
Methods summary
protected
string
|
#
getTagName( )
Returns
string tag name of the button
Overrides
|
public
boolean
|
#
getEnableClientScript( )
Returns
boolean whether to render javascript.
|
public
|
#
setEnableClientScript( boolean $value )
Parameters
- $value
boolean whether to render javascript.
|
protected
|
#
addAttributesToRender( THtmlWriter $writer )
Adds attribute name-value pairs to renderer. This overrides the parent
implementation with additional button specific attributes.
Adds attribute name-value pairs to renderer. This overrides the parent
implementation with additional button specific attributes.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
protected
|
#
renderClientControlScript( mixed $writer )
Renders the client-script code.
Renders the client-script code.
|
protected
string
|
#
getClientClassName( )
Gets the name of the javascript class responsible for performing postback for
this control. This method overrides the parent implementation.
Gets the name of the javascript class responsible for performing postback for
this control. This method overrides the parent implementation.
Returns
string the javascript class name
|
protected
boolean
|
#
canCauseValidation( )
Returns
boolean whether to perform validation if the button is clicked
|
public
|
#
setIsDefaultButton( boolean $value )
Parameters
- $value
boolean set by a panel to register this button as the default button for the panel.
Implementation of
|
public
boolean
|
#
getIsDefaultButton( )
Returns
boolean true if this button is registered as a default button for a panel.
Implementation of
|
protected
boolean
|
#
needPostBackScript( )
Returns
boolean whether the button needs javascript to do postback
|
protected
array
|
#
getPostBackOptions( )
Returns postback specifications for the button. This method is used by
framework and control developers.
Returns postback specifications for the button. This method is used by
framework and control developers.
Returns
array parameters about how the button defines its postback behavior.
|
public
|
#
renderContents( THtmlWriter $writer )
Renders the body content enclosed between the control tag. This overrides the
parent implementation with nothing to be rendered.
Renders the body content enclosed between the control tag. This overrides the
parent implementation with nothing to be rendered.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
public
|
#
onClick( TEventParameter $param )
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.
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.
Parameters
Implementation of
|
public
|
#
onCommand( TCommandEventParameter $param )
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.
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.
Parameters
Implementation of
|
public
|
#
raisePostBackEvent( TEventParameter $param )
Raises the postback event. This method is required by IPostBackEventHandler interface. If getCausesValidation
CausesValidation is true, it will invoke the page's TPage::validate
validate method first. It will raise onClick OnClick and onCommand OnCommand events. This method is mainly used by framework and control
developers.
Raises the postback event. This method is required by IPostBackEventHandler interface. If getCausesValidation
CausesValidation is true, it will invoke the page's TPage::validate
validate method first. It will raise onClick OnClick and onCommand OnCommand events. This method is mainly used by framework and control
developers.
Parameters
Implementation of
|
public
string
|
#
getText( )
Returns
string caption of the button
Implementation of
|
public
|
#
setText( string $value )
Parameters
- $value
string caption of the button
Implementation of
|
public
string
|
#
getData( )
Returns the caption of the button. This method is required by IDataRenderer . It is the same as TButton::getText() .
Returns
string caption of the button.
Since
3.1.0
See
Implementation of
|
public
|
#
setData( string $value )
Sets the caption of the button. This method is required by IDataRenderer . It is the same as TButton::setText() .
Parameters
- $value
string caption of the button
Since
3.1.0
See
Implementation of
|
public
boolean
|
#
getCausesValidation( )
Returns
boolean whether postback event trigger by this button will cause input validation,
default is true
Implementation of
|
public
|
#
setCausesValidation( boolean $value )
Parameters
- $value
boolean whether postback event trigger by this button will cause input validation
Implementation of
|
public
string
|
#
getCommandName( )
Returns
string the command name associated with the onCommand OnCommand event.
Implementation of
|
public
|
#
setCommandName( string $value )
Parameters
- $value
string the command name associated with the onCommand OnCommand event.
Implementation of
|
public
string
|
#
getCommandParameter( )
Returns
string the parameter associated with the onCommand OnCommand event
Implementation of
|
public
|
#
setCommandParameter( string $value )
Parameters
- $value
string the parameter associated with the onCommand OnCommand event.
Implementation of
|
public
string
|
#
getValidationGroup( )
Returns
string the group of validators which the button causes validation upon postback
Implementation of
|
public
|
#
setValidationGroup( string $value )
Parameters
- $value
string the group of validators which the button causes validation upon postback
Implementation of
|
public
TButtonType
|
#
getButtonType( )
Returns
TButtonType
the type of the button. Defaults to TButtonType::Submit.
|
public
|
|
Methods inherited from TWebControl
clearStyle(),
copyBaseAttributes(),
createStyle(),
getAccessKey(),
getBackColor(),
getBorderColor(),
getBorderStyle(),
getBorderWidth(),
getCssClass(),
getDecorator(),
getDisplay(),
getEnsureId(),
getFont(),
getForeColor(),
getHasStyle(),
getHeight(),
getStyle(),
getTabIndex(),
getToolTip(),
getWidth(),
onPreRender(),
render(),
renderBeginTag(),
renderEndTag(),
setAccessKey(),
setBackColor(),
setBorderColor(),
setBorderStyle(),
setBorderWidth(),
setCssClass(),
setDisplay(),
setEnsureId(),
setForeColor(),
setHeight(),
setStyle(),
setTabIndex(),
setToolTip(),
setWidth()
|
Methods inherited from TControl
__construct(),
__get(),
addParsedObject(),
addToPostDataLoader(),
addedControl(),
applyStyleSheetSkin(),
autoBindProperty(),
autoDataBindProperties(),
bindProperty(),
broadcastEvent(),
bubbleEvent(),
clearChildState(),
clearControlState(),
clearNamingContainer(),
clearViewState(),
convertUniqueIdToClientId(),
createChildControls(),
createControlCollection(),
dataBind(),
dataBindChildren(),
dataBindProperties(),
ensureChildControls(),
findControl(),
findControlsByID(),
findControlsByType(),
focus(),
getAdapter(),
getAllowChildControls(),
getAttribute(),
getAttributes(),
getChildControlsCreated(),
getClientID(),
getControlStage(),
getControlState(),
getControls(),
getCustomData(),
getEnableTheming(),
getEnableViewState(),
getEnabled(),
getHasAdapter(),
getHasAttributes(),
getHasChildInitialized(),
getHasControls(),
getHasInitialized(),
getHasLoaded(),
getHasLoadedPostData(),
getHasPreRendered(),
getID(),
getIsSkinApplied(),
getNamingContainer(),
getPage(),
getParent(),
getRegisteredObject(),
getSkinID(),
getSourceTemplateControl(),
getTemplateControl(),
getUniqueID(),
getViewState(),
getVisible(),
hasAttribute(),
initRecursive(),
isDescendentOf(),
isObjectRegistered(),
loadRecursive(),
loadState(),
loadStateRecursive(),
onDataBinding(),
onInit(),
onLoad(),
onUnload(),
preRenderRecursive(),
raiseBubbleEvent(),
registerObject(),
removeAttribute(),
removedControl(),
renderChildren(),
renderControl(),
saveState(),
saveStateRecursive(),
setAdapter(),
setAttribute(),
setChildControlsCreated(),
setControlStage(),
setControlState(),
setCustomData(),
setEnableTheming(),
setEnableViewState(),
setEnabled(),
setID(),
setPage(),
setSkinID(),
setTemplateControl(),
setViewState(),
setVisible(),
trackViewState(),
traverseChildControls(),
unbindProperty(),
unloadRecursive(),
unregisterObject()
|
Methods inherited from TComponent
__call(),
__destruct(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
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
|
|