The Dreamweaver bindings panel has a lot of uses beyond a place to build recordsets and stored procedures. Many people don't realize that when you add session, request, and application variables to the panel manually, you get some visual advantages -- ability to drag items to the page into design view, ability to use variables as filters, and the ability to add formatting functions to design view. This article will explore the bindings panel and it's advantages. Because we are discussing core Dreamweaver functionality, the article will apply equally to all server models in Dreamweaver, although some server models have better bindings panel support than others.

To follow along, you should have the bindings panel open, and a blank page open in your server model of choice.

Note: Dreamweaver's implementation of the bindings panel varies among server models -- in variables available in the bindings panel, and how they are used. Form variables are site-level in a ColdFusion site and page-level in an ASP site, for example.

Session, Form, and Application Variables

When you have a session or application variable defined in your site, it becomes a variable that can be used on any page. In ColdFusion, many of the variables such as form variables are available to the entire site as well. Because of that, it makes sense to put these variables in the bindings panel. Dreamweaver does not detect variables automatically, like it does recordsets and queries, but you can add the variable manually:

1. Click the plus sign (+) in the bindings panel

2. Click Form Variable (or other page-level variable)


Figure 1: Bindings panel in Dreamweaver (ColdFusion server model)

3. Fill in the name of the variable


Figure 2: Adding a Form variable

Now, the variable is available to your site (but no other sites.) This is extremely useful for displaying session variables in other pages, or for setting up form field values.

Local, Form, and other Page-level Variables

Some variables that you define in the bindings panel are available for the page you are currently working on, and not available to other pages. If any variables you use are going to be used as filters in a query, displayed on a page, or used as form field values, it makes sense to define them in the bindings panel. To define a variable, follow the same steps:

  1. Click the plus sign (+) in the bindings panel
  2. Click Local Variable or other page-level variable
  3. Fill in the name of the variable

Using Bindings

Bindings are handy in the following situations:

Displaying a variable

When you want to display a session, form, application, or other variable, simply drag it from the bindings panel onto the page. The page will show a visual representation of the variable:


Figure 3: Displaying dynamic data in Dreamweaver

Formatting a Variable

Once you have the data displayed, you can use the bindings panel to add display formatting functions, directly from the bindings panel. Simply select the data on the page and then scroll far right in the bindings panel -- you'll see an arrow there. Click on the arrow and you'll be able to pull down the menu to add formatting functions:


Figure 4: Adding a format function to a binding

Creating a Link

When you have a binding declared, it is easy to filter a recordset or query by a page parameter. When creating links to point to these pages (like a details page), you can use the property inspector and simply pick the variable from the list. All variables declared in bindings appear in the list. Follow these steps to use a binding to create a link for a details page:

  1. Click the folder icon in the Property Inspector to create a link.
  2. Choose the file to link to.
  3. Click the Parameters button
  4. Fill in the name of the url parameter name, and then click the little lightening bolt icon:


Figure 5: Lightening bolt icon

  1. The dialog that pops up will enable you to grab the variable you want to use to supply the value, whether it's another URL variable or a form variable, session variable, or recordset field:


Figure 6: Picking a variable parameter

  1. Click OK through the dialog boxes and your dynamic link is finished.

The lightening bolt icon is also available in most server behaviors and other extensions. It gives you direct access to the bindings panel from these extensions.

Form Field Values

A form field can take the value of a dynamic field. Typically, if you hand-code your pages, you have to open up source view, find the form field, then type some dynamic code into the value attribute of the field. Using the bindings panel, you can simply drag the dynamic field from the panel and drop it onto a form field. The dynamic value will bind to the form field, filling in the value attribute of form field.

How it works

Binding information is stored in your local site _notes folder. All bindings that are available to the site are stored in a file with no name and an .mno file extension (in other words, the file name is .mno). Bindings that are page-level bindings are stored in a file with the name of the page where the binding appears followed by an .mno extension. For example, a binding on details.php would have a corresponding file called details.php.mno in the _notes folder. Deleting these files also deletes all bindings from your panel. The files are not uploaded to your remote server when synchronizing your sites, but they are stored locally.

Extensions

Below are a couple of extensions that may be of use for you if you want to use bindings panel functionality.

Dreamweaver has no standard way to grab all session and application variables that you have used in your site and put them in the bindings panel. You have to manually add these one by one normally. A free extension I wrote a few years ago will do this automatically:

http://www.tom-muck.com/extensions/help/getalldatasources/

ASP.NET does not have many built in data sources (Dataset and Stored Procedure only), so I built an extension to add Session and Application variables to the bindings panel for ASP.NET users:

http://www.tom-muck.com/extensions/help/MoreDataSources/

Conclusion

This beginners tutorial showed a few ways to use the bindings panel in Dreamweaver for data sources within your site.