diff options
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r-- | framework/Web/UI/WebControls/TButton.php | 21 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TImageButton.php | 19 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TLinkButton.php | 16 |
3 files changed, 52 insertions, 4 deletions
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index aa4e21a7..9f2b2825 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -131,12 +131,29 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr }
/**
+ * @param boolean set by a panel to register this button as the default button for the panel.
+ */
+ public function setIsDefaultButton($value)
+ {
+ $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
+ * @return boolean true if this button is registered as a default button for a panel.
+ */
+ public function getIsDefaultButton()
+ {
+ return $this->getViewState('IsDefaultButton', false);
+ }
+
+ /**
* @return boolean whether the button needs javascript to do postback
*/
protected function needPostBackScript()
{
- //IE needs JS to be rendered for default button to work if no validators are assigned to this button
- return $this->canCauseValidation() || $this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand');
+ return $this->canCauseValidation() || ($this->getButtonType()!==TButtonType::Submit &&
+ ($this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand')))
+ || $this->getIsDefaultButton();
}
/**
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index 41de5087..44d4c14b 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -148,12 +148,27 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven }
/**
+ * @param boolean set by a panel to register this button as the default button for the panel.
+ */
+ public function setIsDefaultButton($value)
+ {
+ $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
+ * @return boolean true if this button is registered as a default button for a panel.
+ */
+ public function getIsDefaultButton()
+ {
+ return $this->getViewState('IsDefaultButton', false);
+ }
+
+ /**
* @return boolean whether the button needs javascript to do postback
*/
protected function needPostBackScript()
{
- //IE needs JS to be rendered for default button to work if no validators are assigned to this button
- return $this->canCauseValidation() || $this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand');
+ return $this->canCauseValidation() || $this->getIsDefaultButton();
}
/**
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index d993b9f5..f92dded3 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -116,6 +116,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC }
/**
+ * @param boolean set by a panel to register this button as the default button for the panel.
+ */
+ public function setIsDefaultButton($value)
+ {
+ $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
+ * @return boolean true if this button is registered as a default button for a panel.
+ */
+ public function getIsDefaultButton()
+ {
+ return $this->getViewState('IsDefaultButton', false);
+ }
+
+ /**
* Renders the Href for link button.
* @param THtmlWriter renderer
*/
|