Skip to Content

Understanding Behaviors and Server Behaviors In Adobe Dreamweaver (Elliot Harris)

Mar 10, 2010

The terms "behavior" and "server behavior" have been in use in Dreamweaver since the days when it was owned by Macromedia. They both refer provide a method of adding interactivity to a web page by generating a variety of scripts which would often be time-consuming to create manually. The difference between the two types of behavior, as the names imply, is that server behaviors generate client-side scripts while server behaviors automatically create server-side code.

Behaviors will always generate code written in JavaScript, by far the most common client-side scripting language in use. The code generated by JavaScript behaviors perform a number of useful function such as plug-in and browser detection and form validation. Some of these behaviors are a bit long in the tooth, have not been updated for several versions of Dreamweaver and, in some cases, have been superseded by Spry, Dreamweaver's implementation of Ajax.

Server behaviors are capable of generating code in any one of the five server-side scripting languages with which Dreamweaver is compatible: ASP, ASP.Net, ColdFusion, JSP and PHP. The language chosen is determined by the language specified as that which should be used on the testing server. This is part of the site definition and dictates the default document type for all new files.

Server behaviors provide Dreamweaver developers with a fairly wide range of features but most of them relate to the manipulation of data objects which are the main thrust of Dreamweaver's server-side development capabilities. One of the first behaviors new Dreamweaver developers will encounter is "Repeat Region". This allows you to select any element or region of a page and specify that it will repeat for as many items as there are in a given set of data. A classic use of this is the repetition of a table row or list item. Naturally, dynamic data, such as a product name, product image, product description, will also be inserted within the area being repeated.

The Show Region server behaviors are also very useful. There are six different variations on the same theme: "Show Region if Recordset is Empty","Show Region if Recordset is not Empty","Show Region if First Record", "Show Region if not First Record", "Show Region if Last Record" and "Show Region if not Last Record".

The "Show Region if Recordset is Empty" and "Show Region if Recordset is not Empty" server behaviors allow developers to create a region of a page which will only be displayed if a given data set is either empty or not empty. So, for example, you would select the entire repeat region mentioned above and use the "Show Region if Recordset is not Empty" behavior. Then you would create a message such as "Sorry, no records match your search criteria.", highlight it and use the "Show Region if Recordset is Empty" to make its display conditional.
About the AuthorThe author is a training consultant with Macresource Computer Solutions, an independent computer training company offering Adobe Dreamweaver Classes in London and throughout the UK..

Similar entries