hub.eb?material_id=277&track_id=284

Before Control Event


A Control's Before Control event is triggered when its Page is displayed for the first time. Before Control events are triggered for each Control, in the order they appear in the Page. These events immediately follow the Page's Before Page event.

A good use case is when the Control is part of a Component. The Control's Before Control event will be executed in the context of the Component, and not the Page the Component has been added to. This means that the Control's Before Control event will work the same way regardless of the Page it has been added to.

In most other cases we would recommend that you attach your code to a Before Form or Before Page event instead to make your application easier to maintain.

 

Steps


1

Create a Form and add a Field called myField and drag it onto the Page.

2

Select the Field Control and edit its Before Control event.

Click on the button to create a new Script. Name the script setMyField.

3

Add the following to the new setMyField script:

/* get the control that owns the event,
 *  in this case it's a field control
 *  so we can call getField() to access
 *  the field it represents
 */
event.owner.getField().value = "Hello, world!";
4

Return to the Form and run it.

The Control will show the new value.

Current Module

Part of tracks

Related