Use client-side events to delay postbacks

Before the .NET target is deployed, you can code client-side events in JavaScript and set properties to reference the JavaScript code that handles client-side events. You must set the properties in #IF DEFINED -#END IF conditional compilation code blocks for .NET targets. The beginning and end tags for these code blocks signal the PowerBuilder native compiler to ignore the code contained inside them.

For more information, see “About conditional compilation”.

The code inside the conditional compilation code blocks is passed to the Web browser client from the server at runtime. You use this code to designate JavaScript functions that handle events on client-side objects. Most events on client-side objects cause a postback to controls on the server side, because the events have server-side analogs that are written originally in PowerScript, then transformed to run in the .NET environment.

If you write any JavaScript code for the client-side events, the postback to the server is interrupted. To resume a postback, you can call the submit method for Web Forms or one of the postback methods generated in the PBDataWindow.JS file. The PBDataWindow.JS file is generated in the Scripts subdirectory of the main project directory under the IIS virtual root.

The postback methods of the PBDataWindow.JS file are described in Chapter 3, “Client-Side Events and Default Event Handlers.”