When creating forms for iOS or Android, there will be times when forms need certain aspects initialized right when the user opens it, however the JavaScript API cannot always script these tasks. 

In these cases, developers should code the necessary initialization in the .NET script and then enable "Run .NET AfterOpen event on sync" on the server for the appropriate form template. This will run the .NET's AfterOpen event on the server when the form template is synced.

It looks like this on the server under a template.

For example, the Grid form control's column headers cannot be initialized or formatted from the JavaScript API. So in the .NET script, under the AfterOpen event, the developer should initialize the Grid and all of its columns like shown below. The JavaScript API can then edit row and cell data for the grid.


If _Grid.Value Is Nothing Then
            Dim dt As New DataTable()
            Dim dc As DataColumn
            dc = New DataColumn("Column1")
            dc = New DataColumn("Column2")
            dc = New DataColumn("Column3")
            dc = New DataColumn("Column4")
            _Grid.Value = dt
End If


Other examples include needing the form to have prepopulated data from a database or file (csv, xml, etc) that is on the server. The form can be scripted to download data from various sources in the .NET AfterOpen event. By scripting it here, the form can access files that are on the server, and not the local machine. 

It is common practice that data downloaded is placed into a hidden field in the .NET script, then in the JavaScript's AfterOpen, which will run AFTER the .NET's AfterOpen, the developer can script it so the form reads and parses the data from the appropriate hidden field.