Using Button and Picture controls

Using Button controls

When a DataWindow object includes a Button control, the button becomes an HTML or XHTML button element in the Form element for the Web DataWindow client control. The button action becomes JavaScript code for the button's Clicked event. You do not need to write any code yourself unless you specify a user-defined action.

You can use Button controls for:

These button actions are not supported and are ignored:

Cancel

QueryClear

Filter

QueryMode

Preview

QuerySort

PreviewWithRulers

SaveRowsAs

Print

Sort

All button actions that reload the page perform an AcceptText before sending data back to the server. If the AcceptText fails (the button action returns -1), this means that pending data changes were not accepted and nothing was sent back to the server. Put code in the server-side AfterPerformAction event to detect and handle the failure appropriately. For more information, see “Handling method failures”.

User-defined actions

If you specify a user-defined action for the button in the DataWindow painter, the ButtonClicked event is triggered when a user clicks the button. You can add a ButtonClicked event handler to the Web DataWindow client control in .NET to perform a different action depending on which button was clicked. For an example, see ButtonClicked.

GIF and JPEG images for buttons

The picture on a button in a DataWindow object can be rendered in the Web browser as a JPEG, GIF, or BMP image. Use a JPEG or GIF image to ensure that the image will display on all browsers.

DataWindow .NET provides GIF images for commonly used buttons such as Retrieve, Update, PageNext, and so on. These pictures are included in the DWACTION.JAR file in the DataWindow Designer 2.0 directory.

To make the images available to the Web page in the Web browser, you must uncompress the JAR file, deploy the image files to the server, and set the HTMLGen.ResourceBase property to the directory where the files are located.

Alternative to buttons: use methods of the client control

If you want to use an existing DataWindow object that does not have Button controls, you can edit the DataWindow object and save a new version with Button controls. However, if you are sharing DataWindow objects with an existing application and it is not practical to edit them, your Web page can include HTML or XHTML buttons that call methods of the Web DataWindow client control.

There are methods of the client control that correspond to each of the supported button actions. For information, see “About client-side programming”.

Using Picture controls

You can use any image types the browser supports, most commonly JPEG or GIF. Use relative paths for ease of deployment.

To make sure the images are available to the Web page in the browser, place the image files in a directory on the Web server and then set the HTMLGen.ResourceBase property to that directory. You can do this in DataWindow Designer on the JavaScript Generation page of the DataWindow property view, or in code:

dwMine.Modify("DataWindow.HTMLGen.ResourceBase=		'C:\InetPub\wwwroot\Images'")

The ResourceBase property also specifies the location of JavaScript include files. See “Using JavaScript caching in DataWindow Designer”.