Writing Server Event Scripts
Web publishing applications only. Server event scripts provide an opportunity to respond to or process the input from a dialog (form) web component. You can run scripts when the following events occur.
Available only for AdvancedButton objects. The OnClick script runs every time the button is clicked.
The Initialize event fires once, the first time the Form is run.
The Validate event fires when a form is submitted.
The AfterValidate event fires after the Validate event.
The Activate event fires every time the form is run.
The Initialize event fires once, the first time the form is run. If the form is submitted back to itself (as is typically the case, so that the values in the Form's controls can be validated), the Initialize event is not fired. The Initialize event is typically used to set initial values for controls on the Form. If you need to execute code every time the Form is run, use the Activate event.
The Validate event fires when a form is submitted. Use this event to check that the value in a control is valid. If your script determines that an error has occurred, then you should set the following object properties:
CurrentControl.Has_Error = .t. CurrentControl.Error_Message = ""
You can also use this syntax:
CurrentForm.Controls..Has_Error = .t. CurrentForm.Controls..Error_Message = ""
If the CurrentControl.Has_Error property is ".T.", then the form will be redisplayed with the error message shown at the top of the form. The user can then make corrections and resubmit the form.
The AfterValidate event fires after the Validate event, but only if no object on the form has had its .Has_Error property set to ".T.". A typical use of the AfterValidate event is to redirect control to another page in the application. For example:
If Condition1 = .t. Then Response.Redirect("Page1.a5w") Else Response.Redirect("Page2.a5w") End If
The Activate event fires every time the form is run. It fires after the Validate and AfterValidate events. A typical use of the Activate event is used to populate drop down list boxes on the form.
When you display the Form Events dialog and select "Declarations" from the Event list box, you to define any User Defined Functions that you want to be available to all Xbasic event code.