CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to set Caption at runtime

Print topic Send  topic

Author Message
vikrant


Posts: 32
Posted: 04/26/2011, 4:59 AM

Hi,

In Editable Grid, How to set Caption at runtime for Textbox?


_________________
Vikrant
View profile  Send private message
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.... :)
View profile  Send private message
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
View profile  Send private message
Waspman

Posts: 948
Posted: 04/28/2011, 7:50 AM

beforshow of the textbox?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
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.... :)
View profile  Send private message
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. :-X
_________________
Vikrant
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.