beautypg.com

Adobe Extending Dreamweaver CS4 User Manual

Page 291

background image

285

EXTENDING DREAMWEAVER CS4

Server behaviors

<% //test_p1 %>

<% //test_p2 %>

These participants are found and matched, and Test appears once in the Server Behaviors panel. If you add the server
behavior again, nothing is added because the participants exist.

If the participants have unique parameters, multiple instances can be inserted above the

html

tag. For example, by

adding a name parameter to the participant, a user can enter a unique name in the Test Server Behavior dialog box. If
the user enters the name aaa, the following participants are inserted:

If you add the server behavior again with a different name, such as bbb, the document now looks like the following
example:

<% //test_p1 name="aaa" %>

<% //test_p2 name="aaa" %>

Two instances of Test are listed in the Server Behaviors panel. If the user tries to add a third instance to the page and
names it aaa, nothing is added because it exists.

Within the

html

tag, matching can also use position information. In the following example, you have two participants,

one that is added before the selection and another that is added after the selection:

<% if (expression) { //mySBName %>

Random HTML selection here:

<% } //end mySBName %>

These two participants are without parameters, so they are grouped. However, you can add another instance of this
server behavior elsewhere in the HTML, as shown in the following example:

<% if (expression) { //mySBName %>

Random HTML selection here:

<% } //end mySBName %>

More HTML here:

<% if (expression) { //mySBName %>

Another HTML selection here:

<% } //end mySBName %>

Now, you have two identical instances of each participant, which is allowed within the HTML. Dreamweaver matches
them by the order in which they occur in the document.

The following example shows a matching problem and how to avoid it. You can create a participant that computes the
tax on some dynamic data and displays the result at the selection.

<% total = Recordset1.Fields.Item("itemPrice").Value * 1.0825 %>


The total (with taxes) is $<%=total%>


The two participants are matched because they have no common parameters. However, if you add a second instance
of this server behavior, you must have the following code:

This manual is related to the following products: