Справочник Пользователя для Macromedia dreamweaver 8-extending dreamweaver

Скачать
Страница из 504
372
Server Behaviors
There are two instances of Test 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 already exists.
Within the 
html
 tag, matching can also use position information. In the following example, 
there are 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 together. 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 there are two identical instances of each participant, which is allowed within the 
HTML. They are matched 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 %>
<html>
<body>
The total (with taxes) is $<%=total%>
</body>
</html>
The two participants are matched because they have no common parameters. However, if you 
add a second instance of this server behavior, you should have the following code:
<% total = Recordset1.Fields.Item("itemPrice").Value * 1.0825 %>
<% total = Recordset1.Fields.Item("salePrice").Value * 1.0825 %>
<html>
<body>
The total  (with taxes) is $<%=total%>
Sale price (with taxes) is $<%=total%>
</body>
</html>