Label and Literal Control Options

Go to:

Tools, Properties..., Display tab

The Label control displays a database field label.

Label and Literal control options.

 

Options

Description

Display this when field contains a value

Formats text to be displayed on the web page.  Any text and HTML may be included, such as HTML formatting tags.

{0} is a substitution variable that signifies the database value.

See Conditional field value display for details.

Display this text when field is empty

Specifies the text to be displayed or inserted into the database if the underlying database field has a “null” value (no value).  Any text and HTML may be included, such as HTML formatting tags.

See Conditional field value display for details.

White space encoding

No Encoding

Full wrapping is permitted using all white space characters.

HTML encode white space with no wrapping

Respects the white space, carriage return and line feed characters in the HTML.  White space is preserved.  For example, if you have 10 contiguous spaces, 10 spaces will be output in the field.

HTML encode white space with wrapping allowed

Limited wrapping is permitted.

Save field value to database

Sets the "SaveData=True" pass-through attribute value so that any automatically initialized value is saved to the database.  (Values in Labels and Literals are not automatically saved to the database, unlike control types normally used for data input, such as text boxes and list boxes).

You can initialize field values using the Set Initial Value To properties.  See FieldValue Initial Value Properties for details.

Display text as

Specifies how to display the text contained in the field.

HTML source

Display the text without rendering (executing) HTML tags.  Any embedded HTML tags are displayed as ‘HTML source’.

Rich text

Display the text as rich text.  Embedded HTML tags are rendered.

Note that rich text is displayed only if the text can be fully displayed.  The amount of text in the field, including embedded HTML tags, must be less than the FieldMaxLength pass-through attribute’s value.

When text is truncated, it is appended with ellipses and is shown as HTML encoded using the default browser font.  However if the text fits completely into the cell it will be shown as a rich text.

See Handling rich text display for additional details.

Default

Use the Application Generation Options setting.

Conditional field value display

Any combination of text, HTML and the actual database value can be displayed.  The following examples illustrate how text, HTML and the database field value can be combined.

Display this when field contains a value

Displays as

Purpose

{0}

William

Displays the database field value.

<font color=”red”>{0}</font>

William

Displays the database field value in red.

<a href=”mailto:{0}”>{0}</a>

bill@ironspeed.com

Displays a ‘mailto’ email link.  The field should contain a valid email address.

<a href=”{0}”>{0}</a>

www.ironspeed.com

Displays a clickable URL (hyperlink) from the database.  The field should contain a valid URL.

<a href=”{0}” target=”_blank”>{0}</a>

www.ironspeed.com

Displays a clickable URL (hyperlink) from the database.  The field should contain a valid URL.  When clicked, a new browser window is opened with the hyperlinked page.

<a href=”http://www.ironspeed.com/kb?q={0}”>
Search for {0}</a>

Search for William

Displays a clickable URL (hyperlink) as part of a query string.  The field should contain a valid URL.

<img src="{0}" />

Displays an image if the field contains a valid URL.

Conditional image display

The conditional display feature is frequently used to display ‘not available’ or ‘image not found’ when fields are emplty.  The example below illustrates how an image can be displayed from the database field containing a URL.  If the field is empty, a ‘no image available’ default image is displayed instead.

Step 1:  Set the Control Type to ‘Literal’ to enable the conditional display feature.  Conditional display is available for the Label and Literal control types.

Step 2:  Use an <img> tag to display an image using the URL stored in the database field.

Step 3:  Use an <img> tag to display a default ‘no image available’ image when the database field is empty, i.e., it does not contain a URL.

Displaying hyperlinked URLs (clickable fields)

The conditional display feature can be used to display hyperlinked (clickable) URLs if your database field contains a URL.

Step 1:  Set the Control Type to ‘Literal’ to enable the conditional display feature.

Step 2:  Use an <a href> tag to display a clickable URL using the URL stored in the database field.

Step 3:  Build and run your application.

If the database field only contains a page or file name and not a fully qualified URL, the <a href> tag can be expanded to add a prefix to the location containing the file, e.g.:

<a href=”http://www.ironspeed.com/{0}”>{0}</a>

You can open the hyperlinked page in a new browser window by providing a “target” attribute, e.g.:

<a href=”{0}” target=”_blank”>{0}</a>

Handling rich text display – text display is truncated

When displaying fields as ‘rich text’ it is common for records with smaller amounts of text to be displayed as rich text and for records with larger amounts text to be truncated and displayed in the browser font because there isn’t sufficient room to display them as rich text.  This can lead to a situation where the fonts in certain table cells differ markedly.  Most likely your field is set to show text as Default, allowing the Application Generation Options to decide how to display the text.  If set to Display text as ‘Rich text’ and the threshold is low enough that this field qualifies to use rich text, then any cell in this column where text fits completely will be shown as a rich text; any cell where the text length exceeds the cell width will be truncated and displayed in the default browser font.

To show all text using the same font, you can do one of the following:

See Also

FieldValue Tag

FieldValue Control Type Properties

FieldValue Display Format Properties

Label and Literal Control Options

File Upload and File Download Control Options

List Control Options

Text Box Control Options

FieldValue Initial Value Properties

FieldValue Binding Properties

FieldValue Pass-Through Attributes