Skip to main content

Form Binding

CSP supports the cspbind attribute for HTML forms and other input controls. Use this attribute to bind objects and their properties to the HTML controls. This allows the controls to display and update the values of the bound object's properties. When the page loads, the controls display the property values. When the form is submitted, the values of the properties are updated.

Here are the steps for binding an object to an HTML form and properties of the object to the form's input controls:

  1. Use <csp:object> to open an object on the page.

  2. Add a cspbind attribute to the <form> tag. The value of cspbind matches the value of the <csp:object> tag's name attribute.

  3. Add a cspbind attribute to the <input> tag. The value of the cspbind attribute matches the name of the bound property.

Here is an example:

<csp:object name="contact" classname="CSPTutorial.Contact" objid="1"/>
<form name="MyForm" cspbind="contact">
<input type="text" name="txtContactType" cspbind="ContactType"/>

When an object is bound to a form, the CSP compiler automatically generates the following code:

  • Client-side JavaScript that performs required field checking and other basic form validation.

  • Client-side JavaScript that invokes server-side methods to save the bound object.

  • A hidden form-field, OBJID, that contains the object's id value.

  • Server-side methods that validate and save data input to the form


For a complete list of HTML Input elements that support cspbind, read the discussion of “Binding Data to Forms” in the Building Database Applications section of Using Caché Server Pages .

FeedbackOpens in a new tab