Dreamweaver

Request a parameter for the server behavior

Server behaviors often require that the page designer supply a parameter value. This value must be inserted before the server behavior’s code is inserted into the page.

You create the dialog box by defining the designer-supplied parameters in the code. Then you generate a dialog box for the server behavior, which prompts the page designer for a parameter value.

Note: A parameter is added to your code block without your intervention if you specify that your code should be inserted relative to a specific tag chosen by the page designer (that is, you chose Relative to a Specific Tag in the Insert Code pop‑up menu). The parameter adds a tag menu to the behavior’s dialog box to let the page designer select a tag.

Define the parameter in the server behavior code

  1. Enter a parameter marker in the code where you want to insert the supplied parameter value. The parameter has the following syntax:
    @@parameterName@@
  2. Enclose the formParam string in parameter markers (@@):
    <% Session(“lang_pref”) = Request.Form(“@@formParam@@”); %>

    For example, if the server behavior contains the following code block:

    <% Session(“lang_pref”) = Request.Form(“Form_Object_Name”); %>
    To require the page designer supply the value of Form_Object_Name, enclose the string in parameter markers (@@):
    <% Session(“lang_pref”) = Request.Form(“@@Form_Object_Name@@”); %>

You can also highlight the string and click the Insert Parameter In Code Block button. Enter a parameter name and click OK. Dreamweaver replaces every instance of the highlighted string with the specified parameter name enclosed in parameter markers.

Dreamweaver uses the strings that you enclose in parameter markers to label the controls in the dialog box it generates (see the following procedure). In the previous example, Dreamweaver creates a dialog box with the following label:

Dialog box with label

Note: Parameter names in the server behavior code cannot have any spaces. Therefore, the dialog box labels cannot have any spaces. If you want to include spaces in the label, you can edit the generated HTML file.

Create a dialog box for your server behavior to request the parameter value

  1. In the Server Behavior Builder, click Next.
  2. To change the display order of the dialog box controls, select a parameter and click the up and down arrows.
  3. To change a parameter’s control, select the parameter and selecting another control in the Display As column.
  4. Click OK.

    Dreamweaver generates a dialog box with a labeled control for each designer-supplied parameter that you defined.

View the dialog box

 Click the Plus (+) button in the Server Behaviors panel (Window > Server Behaviors), and select your custom server behavior from the pop‑up menu.

Edit the dialog box you created for the server behavior

  1. In the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button, and select Edit Server Behaviors from the pop‑up menu.
  2. Select your server behavior from the list, and click Open.
  3. Click Next.

    A dialog box appears listing all the designer-supplied parameters that you defined in your code.

  4. To change the display order of the dialog box controls, select a parameter and click the up and down arrows.
  5. To change a parameter’s control, select the parameter and select another control in the Display As column.
  6. Click OK.