• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Working with Text > Working with Dynamic Text Elements

Working with Dynamic Text Elements

Dynamic text elements are the contents of database fields, placed in your page as text. Prices, names of things, and descriptions are all good candidates to be inserted as text elements. Depending on how much text the database field contains, the dynamic element can be as short as a few letters or words, or as long as several paragraphs. Dynamic text elements all appear as placeholders in Design view:


Or in Code view:


Remember, the placeholder is not an indication of how much room the actual text will take up.

Inserting Dynamic Text

The simplest way to insert dynamic text into a document is to drag a recordset field from the Bindings panel into the Document window, wherever you want your text to appear (see Figure 4.17). After the text is in place, the Server Behaviors panel will show that a new Dynamic Element behavior has been added to the document.

Figure 4.17. Dynamic text, formatted as a list item and set to be a repeating region.

Formatting Dynamic Text

Any formatting you would normally apply to text, you can apply to the placeholder for dynamic text. Just select it and use the Property inspector or CSS panel as you normally would. If you look at your page in Code view, you’ll see that the formatting code is wrapped around the placeholder code—like this:


Applying Prefab Formatting

You can tell Dreamweaver to build certain formatting instructions into the page code—things like adding dollar signs or other currency symbols to numbers, displaying numbers with only a set number of decimal points, applying capitalization to text, and so forth. Do this:

Insert some dynamic text.

In the Server Behaviors panel, find the behavior that corresponds to the text you want to format.


When you select a placeholder in Design view, the behavior responsible for creating that item should highlight in the Server Behaviors panel.

Double-click the server behavior to edit it.

In the dialog box that appears, choose your desired formatting from the pop-up Format list. When you’re done, click OK.

Interspersing Dynamic Text with Regular Text

You can mix and match dynamic text placeholders and actual text any way you like. Two placeholders can be placed in subsequent paragraphs, or separated only by a space, or right next to each other—whatever you need.

This code:

The lovely <%=(Recordset1.Fields.Item("category").Value)%> in our 
jewelry collection are from known artists. The current page shows 
<%=(Recordset1.Fields.Item("artistname").Value)%>'s most prized 

Will generate HTML like this:

The lovely bracelets in our jewelry collection are from known 
artists. The current page shows Duncan Smith's most prized works.

Using Text Chunks as Repeated Regions

Any chunk of HTML code—including individual words, lines, and list items—can be turned into repeating regions that will display multiple records from a database. To turn a piece of text into a repeating region, simply select it and, from the Server Behaviors panel, choose Repeat Region.


Make sure you have selected carefully, so you’re repeating exactly the code you want—this might mean working in Code and Design view so you can see the HTML source as you work. To repeat a list item, for instance, you want to make sure the opening and closing <li> tags are both selected, but not the <ul> or <ol> tags around them.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint