Class \Prado\Web\UI\WebControls\TButton
TButton creates a click button on the page. It is mainly used to submit data to a page.
TButton raises two server-side events, \Prado\Web\UI\WebControls\onClick and \Prado\Web\UI\WebControls\onCommand, when it is clicked on the client-side. The difference between these two events is that the event \Prado\Web\UI\WebControls\onCommand is bubbled up to the button's ancestor controls. And within the event parameter for \Prado\Web\UI\WebControls\onCommand contains the reference to the \Prado\Web\UI\WebControls\setCommandName and \Prado\Web\UI\WebControls\setCommandParameter 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 \Prado\Web\UI\WebControls\setCausesValidation is true. The validation may be restricted within a certain group of validator controls by setting \Prado\Web\UI\WebControls\setValidationGroup property. If validation is successful, the data will be post back to the same page.
TButton displays the \Prado\Web\UI\WebControls\setText property as the button caption.
TButton by default renders an input tag; the \Prado\Web\UI\WebControls\setButtonTag property can be used to render a button tag (introduced in html5).
TButton can be one of three \Prado\Web\UI\WebControls\setButtonType: 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 \Prado\Web\UI\WebControls\onClick event;
- an event handler is attached to \Prado\Web\UI\WebControls\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.
Class hierarchy
- \Prado\Web\UI\WebControls\TButton implements IPostBackEventHandler, IButtonControl, IDataRenderer
- \Prado\Web\UI\WebControls\TWebControl implements IStyleable
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.0
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
getData() : string
Returns the caption of the button.
This method is required by IDataRenderer. It is the same as getText(). |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
onClick(TEventParameter $param) : mixed
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. |
public
|
onCommand(TCommandEventParameter $param) : mixed
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. |
public
|
raisePostBackEvent(TEventParameter $param) : mixed
Raises the postback event.
This method is required by IPostBackEventHandler interface. If \Prado\Web\UI\WebControls\getCausesValidation is true, it will invoke the page's \Prado\Web\UI\TPage::validate method first. It will raise \Prado\Web\UI\WebControls\onClick and \Prado\Web\UI\WebControls\onCommand events. This method is mainly used by framework and control developers. |
public
|
renderContents(THtmlWriter $writer) : mixed
Renders the body content enclosed between the control tag.
This overrides the parent implementation with nothing to be rendered for input tags, button tags are rendered normally. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
setData(string $value) : mixed
Sets the caption of the button.
This method is required by IDataRenderer. It is the same as setText(). |
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
addAttributesToRender(THtmlWriter $writer) : mixed
Adds attribute name-value pairs to renderer.
This overrides the parent implementation with additional button specific attributes. |
protected
|
|
protected
|
getClientClassName() : string
Gets the name of the javascript class responsible for performing postback for this control.
This method overrides the parent implementation. |
protected
|
getPostBackOptions() : array<string|int, mixed>
Returns postback specifications for the button.
This method is used by framework and control developers. |
protected
|
|
protected
|
|
protected
|