From 1ba083b9bf77b334b773b84d4d9e5f44319d17a2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 2 Apr 2007 06:19:55 +0000 Subject: Fixed #585, #586 --- framework/Web/UI/WebControls/TButton.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI/WebControls/TButton.php') 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 @@ -130,13 +130,30 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr return false; } + /** + * @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(); } /** -- cgit v1.2.3