Understanding Behaviors and Server Behaviors In Adobe Dreamweaver

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.

Dreamweaver Behaviors will always generate code written in JavaScript, by far the most commonly-used client-side scripting language. 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 can generate code in 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 offer 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.

Another very handy series of Dreamweaver server behaviors is Show Region which has 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 first two variations 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.

The writer of this article is part of an organisation that offers training courses on Adobe Dreamweaver in London and throughout the UK.

Posted in Uncategorized

Leave a Reply