Skip to main content

Form Lifecycle and Events

lifecyle

Client and Server Difference

The main difference between Client and Server is that the client is a machine or program that requests services over the web, and the server is a machine or program that provides services to clients according to the client's requests. Client events should be preferred if you want to assign a value to any object on the form at a certain moment, or if you want to check whether the objects are visible, whether value entry is allowed, whether there are mandatory fields to be filled. The main reason for this is the slowness caused by communicating with the server in a coding process to be done on the server side. However, during any event, if you want to pull data from a data source by writing code, it is more accurate to write it on the Server side. The main reason for this is to prevent the formation of security weaknesses in the application.

INFO

With the developer tools of the browsers, the codes can be written, debugged and the tests of the written codes can be performed without the need to republish the project on the client side.

Form Events

OnInit The OnInit event is an event that is triggered at the moment the form is initialized (initialize). This event occurs while the form is loading or being created. The OnInit event is raised at the beginning of the page's lifecycle. It is used to perform operations that must be performed during the initial initialization of the form. These operations typically include setting initial values, loading resources, creating database connections, creating other components, or setting the initial state of the form.

OnLoad An OnLoad event is an event that is triggered when the form loads. This event occurs at the time that the form is displayed to the user. The OnLoad event is used to perform the operations that need to be done after the form is loaded. These operations are usually related to the user interface. For example, upon full loading of the form, operations such as changing the text or images in the form, displaying a message to the user, pulling data from the database, or creating other dynamic content can be performed in the OnLoad event.

OnPropertyChanged The OnPropertyChanged event is an event that is triggered when there is a change in the properties of the form. This event is triggered automatically when the value of a property changes and is used to track or react to that change. The OnPropertyChanged event is typically used to facilitate communication between objects and data updates. When a property of an object changes, other objects may need to be aware of that change and react appropriately. The OnPropertyChanged event is used as a means to provide this communication.

OnClick An OnClick event is an event that is triggered when you click anywhere on the form. This event occurs when the user clicks a button, an object area, an image, or another item with the mouse. The OnClick event is used to detect the user's interaction and react appropriately to that interaction. The operations that are desired to be performed when an item is clicked are defined in the onClick event. These operations can be, for example, calling a method, changing the value of an object, or changing the appearance of an element.

OnPreRender An OnPreRender event is an event that is triggered before the form is rendered (rendered). This event occurs just before the form is fully processed and displayed to the user. The OnPreRender event is used to make final edits to the form or perform final checks. This can include updating data on the form, changing the appearance or status of controls, or making other final edits.

OnBeforeSave The OnBeforeSave event is an event that is triggered before the form is saved (save). This event occurs before the save operation begins and provides control over the process of saving the form and data. The OnBeforeSave event can usually be performed to verify the validity of the data, save changes, or perform other pre-save checks.

OnAfterSave The OnAfterSave event is an event that is triggered after the form is saved (save). This event is used to perform operations that must be performed after the save operation. The OnAfterSave event is typically used in database operations, updating the status of data, displaying post-save messages, triggering workflow, or other post-save operations.

OnBeforeCommit The OnBeforeCommit event is an event that is triggered before the form is registered (commit) to the database. This event occurs before you reach the step of saving to the database to perform the operation. The OnBeforeCommit event is used for final checks or operations performed before completing the transaction. In this case, operations such as checking the accuracy of the data in the transaction, showing error or warning messages during the process, or performing other pre-saving checks can be performed.

OnCommit An OnCommit event is an event that is triggered immediately after the database operation completes. This event is used to perform related post-processing operations after the operation is complete. The OnCommit event is triggered when any event occurs on the form, such as saving the form, sending it for approval, etc.

OnRollBack An OnRollBack event is an event that is triggered when a transaction or database transaction is rollback. This event is used to perform related post-processing operations after the transaction is rolled back. The OnRollBack event is typically used in database transactions and is used for operations that must be performed after the transaction is rolled back. In this event, data restore, logging, error handling, or other post-rollback operations can be performed after the transaction is rolled back.

OnValidating An OnValidating event is an event that is triggered during the validation process of an input. It is used to check the validity of the data received from the user. This event is used to check whether the data is valid, catch errors, check for required fields, and provide feedback to the user. After the OnBeforeSave event, it runs before the OnAfterSave event.

OnToolbarButtonClicked The OnToolbarButtonClicked event is an event that is triggered when a toolbar button defined on the form is pressed. It can be used when you want to make changes or controls in any field on the form, when you want to open a new form or download a document on an existing form.

OnUnload An OnUnload event is an event that is triggered when the form is abandoned (unloaded) by the user. This event occurs when the user leaves or refreshes the page. The OnUnload event is used to perform the operations that need to be done when the form is closed. These operations include operations such as releasing resources, saving data, or performing other cleanup operations before leaving the form. This event is triggered when a user fills out a form and leaves the page, and operations such as sending the data in the form to the server or saving it to a database can be performed.

OnChildFormReturn The OnChildFormReturn event is the event that captures the values returned from the current form if there is a different form to which it is linked.

Order in which events are triggered

After the form opens, the OnInit > OnPreRender > OnLoad > OnRender > OnPropertyChanged > OnRender events run, respectively. When the form is saved > advanced through the flow, the OnBeforeCommit OnBeforeSave > OnRender > OnAfterSave > OnCommit events run, respectively.