Standard pattern for handling events in an HTML Widget, including returning HTML and processing actions.

Key Objects Used

Code

' HTML Widget event handler — called for each user interaction
' eventId: "" for initial page load, or a custom event name
' parametersJson: JSON parameters from the client-side JavaScript
' returnValue: set this to return HTML content or JSON data

Dim Parameters As ISKeyValueList = finBL.CreateKeyValueList()
Parameters.FromSimpleJsonString(parametersJson)

' Handle Events
Select Case eventId
  Case ""
    ' Initial page load — return the HTML template
    returnValue = ScriptInfo.TemplateText

  Case "GetData"
    ' Custom event — return JSON data
    Dim result As String = ""
    finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(myData, result)
    returnValue = result

  Case "Save"
    ' Custom event — process a save action
    Dim name As String = Parameters.GetString("Name")
    Dim value As Decimal = Parameters.GetDecimal("Value")
    ' ... process the save ...
End Select
Source:
Sample Scripts / Common HTML Widget pattern