Dreamweaver

Complete the update page block by block

An update page has three building blocks:

  • A filtered recordset to retrieve the record from a database table
  • An HTML form to let users modify the record’s data
  • An Update Record server behavior to update the database table

    You can add the final two basic building blocks of an update page separately using the form tools and the Server Behaviors panel.

Add an HTML form to an update page

  1. Create a page (File > New > Blank Page). This becomes your update page.
  2. Lay out your page using the Dreamweaver design tools.
  3. Add an HTML form by placing the insertion point where you want the form to appear and selecting Insert > Form > Form.

    An empty form is created on the page. You may have to enable Invisible Elements (View > Visual Aids > Invisible Elements) to see the form’s boundaries, which are represented by thin red lines.

  4. Name the HTML form by clicking the <form> tag at the bottom of the Document window to select the form, opening the Property inspector (Window > Properties), and entering a name in the Form Name box.

    You don’t have to specify an action or method attribute for the form to tell it where and how to send the record data when the user clicks the Submit button. The Update Record server behavior sets these attributes for you.

  5. Add a form object such as a text field (Insert > Form > Text Field) for each column you want to update in the database table.

    The form objects are for data entry. Text fields are common for this purpose, but you can also use menus, options, and radio buttons.

    Each form object should have a corresponding column in the recordset you defined earlier. The only exception is the unique key column, which should have no corresponding form object.

  6. Add a Submit button to the form (Insert > Form > Button).

    You can change the label of the Submit button by selecting the button, opening the Property inspector (Window > Properties), and entering a new value in the Label box.

Display the record in the form

  1. Make sure you defined a recordset to hold the record the user wants to update.

    See Retrieve the record to update.

  2. Bind each form object to data in the recordset, as described in the following topics:

Add a server behavior to update the database table

  1. In the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button and select Update Record from the pop‑up menu.

    The Update Record dialog box appears.

  2. Select a form from the Submit Values From pop‑up menu.
  3. In the Data Source or Connection pop‑up menu, select a connection to the database.
  4. Enter your user name and password if applicable.
  5. In the Update Table pop‑up menu, select the database table that contains the record you are updating.
  6. (ColdFusion, PHP, ASP.NET) Specify a database column to update, select the form object that will update the column from the Value pop‑up menu, select a data type for the form object from the Submit As pop‑up menu, and select Primary Key if you want to identify this column as the primary key.

    The data type is the kind of data the column in your database table is expecting (text, numeric, Boolean option values).

    Repeat the procedure for each form object in your form.

  7. (ASP, JSP) In the Select Record From pop‑up menu, specify the recordset that contains the record displayed in the HTML form. In the Unique Key Column pop‑up menu, select a key column (usually the record ID column) to identify the record in the database table. Select the Numeric option if the value is a number. A key column usually accepts only numeric values, but sometimes accepts text values.
  8. In the After Updating or On Success, Go To box, enter the page to open after the record updates in the table or click the Browse button to browse to the file.
  9. (ASP.NET) In the On Failure, Go To box, enter the location of a page to display if the server behavior fails or click the Browse button to browse to the location.
  10. (ASP.NET) Select the Display Debugging Information On Failure option if you want debugging information when the server behavior fails. When you select this option, Dreamweaver ignores the On Failure, Go To Option.
    Use the debugging option during development and use the OnFailure, GoTo option when your site is live.
  11. (ASP, JSP) Specify a database column to update, select the form object that will update the column from the Value pop‑up menu, and then select a data type for the form object from the Submit As pop‑up menu. The data type is the kind of data the column in your database table is expecting (text, numeric, Boolean option values). Repeat the procedure for each form in your form.
  12. Click OK.

    Dreamweaver adds a server behavior to the page that lets users update records in a database table by modifying the information displayed in the HTML form and clicking the Submit button.

    To edit the server behavior, open the Server Behaviors panel (Window > Server Behaviors) and double-click the Update Record behavior.