summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page9
-rw-r--r--demos/quickstart/protected/pages/Controls/Simple.page7
-rw-r--r--framework/Web/UI/TPage.php12
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php2
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php9
5 files changed, 17 insertions, 22 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page
index 246ecfec..f771b2ba 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page
@@ -58,12 +58,13 @@ Auto postback text box not causing validation:
Auto postback text box causing validation:
</td><td class="sampleaction">
<com:TTextBox ID="TextBox3"
+ Width="300px"
AutoPostBack="true"
ValidationGroup="Group1"
- Text="change me" />
+ Text="change me to 'test' and see" />
<com:TRequiredFieldValidator
ControlToValidate="TextBox3"
- ErrorMessage="You must enter 'test'."
+ ErrorMessage="You must enter a value not equal to 'test'."
InitialValue="test"
ValidationGroup="Group1" />
</td></tr>
@@ -157,10 +158,10 @@ Auto postback text box causing validation:
TextMode="MultiLine"
AutoPostBack="true"
ValidationGroup="Group2"
- Text="change me" />
+ Text="change me to 'test' and see" />
<com:TRequiredFieldValidator
ControlToValidate="MultiTextBox3"
- ErrorMessage="You must enter 'test'."
+ ErrorMessage="You must enter a value not equal to 'test'."
InitialValue="test"
ValidationGroup="Group2" />
</td></tr>
diff --git a/demos/quickstart/protected/pages/Controls/Simple.page b/demos/quickstart/protected/pages/Controls/Simple.page
index f6f981c4..a244429d 100644
--- a/demos/quickstart/protected/pages/Controls/Simple.page
+++ b/demos/quickstart/protected/pages/Controls/Simple.page
@@ -39,6 +39,13 @@
<com:RunBar PagePath="Controls.Samples.TTextBox.Home" />
<h2>TButton</h2>
+<p>
+<tt>TButton</tt> creates a click button on a Web page. The button's caption is specified by <tt>Text</tt> property. A button is used to submit data to a page. <tt>TButton</tt> raises two server-side events, <tt>Click</tt> and <tt>Command</tt>, when it is clicked on the client-side. The difference between <tt>Click</tt> and <tt>Command</tt> events is that the latter event is bubbled up to the button's ancestor controls. A <tt>Command</tt> event handler can use <tt>CommandName</tt> and <tt>CommandParameter</tt> associated with the event to perform specific actions.
+</p>
+<p>
+Clicking on button can trigger form validation, if <tt>CausesValidation</tt>is true. And the validation may be restricted within a certain group of validator controls according to <tt>ValidationGroup</tt>.
+</p>
+<com:RunBar PagePath="Controls.Samples.TButton.Home" />
<h2>TLinkButton</h2>
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index ba0d8003..1dcc0b99 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -287,17 +287,9 @@ class TPage extends TTemplateControl
if($this->_validators && $this->_validators->getCount())
{
Prado::trace("Page validate",'System.Web.UI.TPage');
- if($validationGroup==='')
- {
- foreach($this->_validators as $validator)
+ foreach($this->_validators as $validator)
+ if($validator->getValidationGroup()===$validationGroup)
$validator->validate();
- }
- else
- {
- foreach($this->_validators as $validator)
- if($validator->getValidationGroup()===$validationGroup)
- $validator->validate();
- }
}
}
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index 2d1dd612..df6c2abf 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -36,7 +36,7 @@ class TRequiredFieldValidator extends TBaseValidator
*/
public function getInitialValue()
{
- $this->getViewState('InitialValue','');
+ return $this->getViewState('InitialValue','');
}
/**
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index 111fec1e..276982ac 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -232,13 +232,8 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
*/
public function raisePostDataChangedEvent()
{
- $page=$this->getPage();
- if($this->getAutoPostBack() && !$page->getPostBackEventTarget())
- {
- $page->setPostBackEventTarget($this);
- if($this->getCausesValidation())
- $page->validate($this->getValidationGroup());
- }
+ if($this->getAutoPostBack() && $this->getCausesValidation())
+ $this->getPage()->validate($this->getValidationGroup());
$this->onTextChanged(null);
}