vikrant
Posts: 32
|
| Posted: 04/26/2011, 4:59 AM |
|
Hi,
In Editable Grid, How to set Caption at runtime for Textbox?
_________________
Vikrant |
 |
 |
damian
Posts: 838
|
| Posted: 04/26/2011, 5:31 AM |
|
use a Before Show event?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
vikrant
Posts: 32
|
| Posted: 04/26/2011, 6:26 AM |
|
I have tried it in different events but still it takes caption from design time property.
_________________
Vikrant |
 |
 |
Waspman
Posts: 948
|
| Posted: 04/28/2011, 7:50 AM |
|
beforshow of the textbox?
_________________
http://www.waspmedia.co.uk |
 |
 |
damian
Posts: 838
|
| Posted: 04/28/2011, 2:54 PM |
|
is your caption text or is it a label? if the caption is text (which the builder generates) then it will always be text.
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
vikrant
Posts: 32
|
| Posted: 04/28/2011, 10:17 PM |
|
TextBox has Caption property which is the name of control to be used in error messages. I want to change this Caption at runtime.
_________________
Vikrant |
 |
 |
Waspman
Posts: 948
|
| Posted: 04/29/2011, 1:33 AM |
|
AHH, sorry I being thick. So you want to change the caption, the name of the control... Why?
_________________
http://www.waspmedia.co.uk |
 |
 |
datadoit
|
| Posted: 04/29/2011, 6:08 AM |
|
This might be possible with PHP ternary operator usage. Try something like:
" . $this->YourField->Value() ? "This caption" : "That caption" . "
|
|
|
 |
vikrant
Posts: 32
|
| Posted: 05/02/2011, 5:42 AM |
|
I want to change 'Caption' i.e. set caption property of textbox control. If I use
echo $Form_Name->Control_Name->Caption; then it gives me design time caption of control; but still I am not able to change it at runtime!!!
_________________
Vikrant |
 |
 |
Waspman
Posts: 948
|
| Posted: 05/02/2011, 7:06 AM |
|
Where are you gona get the runtime name from?
If it's set in the db the you could insert an artibute in the html i.e. name="atribute"
or if you know what the runtime name is why not just edit the html.
?
_________________
http://www.waspmedia.co.uk |
 |
 |
datadoit
|
| Posted: 05/02/2011, 7:20 AM |
|
I just tested my suggestion to use the PHP ternary operator, and it does
work. This goes into the Caption property:
" . $this->Field1->Value == 'whatever' ? "Howdy" : "Hello" . "
The caveat is that you can only test for the condition of a field value
for a field that has already been defined BEFORE your field that you're
attempting to dynamically alter the caption for. You can get around
this by defining a hidden field before the field that you're using the
dynamic caption in. Hope that makes sense. Just note that whatever you
put into this caption property field goes into the page's PHP code (not
the _events.php code). Therefore it gets loaded before any custom code
events are loaded.
Another issue with this is that now using translations won't work for
the field.
Regardless, let's look at 'why' you're wanting to change the caption, as
there may be a much better and easier way. Recognize that changing the
caption property only effects the field name display should there be an
error on form submission. ie: The above example will produce:
"The value in field Hello is required."
The very easiest way is to simply check for an error in the field's
OnValidate event and use a custom error message with:
$Container->Errors->addError("Oops!");
See: http://docs.codecharge.com/studio40/html/ProgrammingTec...essage.html?toc
|
|
|
 |
Waspman
Posts: 948
|
| Posted: 05/03/2011, 12:42 AM |
|
and if it is just about error messages why not use jQuery.
_________________
http://www.waspmedia.co.uk |
 |
 |
vikrant
Posts: 32
|
| Posted: 05/03/2011, 2:05 AM |
|
Atlast I found solution…
I just copy paste line from: Class_Initialize Event & Validate Method
which is auto generated for each control:
$this->control_name = & new clsControl(); //This function contains caption!!
$this->control_name->SetText(); //to validate with above line...
into on validate event and now it works… 
thanks to all for your help.
_________________
Vikrant |
 |
 |