Control events in the Events developer sample form

Microsoft Office InfoPath

Show All Show All

Control events in the Events developer sample form

The Events developer sample form implements a single Microsoft Office InfoPath 2003 control event that can respond to a button click; this is the OnClick event. The OnClick event occurs after a user clicks a button on a form.

Note  The OnClick event is the only control event supported by InfoPath.

To use the OnClick event, you must first create the event in the Button Properties dialog box that is available on the shortcut menu for the button control. On the General tab, set Script as the Action, and then click Microsoft Script Editor. This will open Microsoft Script Editor (MSE) and display the InfoPath-generated event handler.

Note  Event handlers in InfoPath must be created in design mode.

In the Events developer sample form, the OnClick event is implemented for the three buttons that are used to switch between views. The following example from the Events developer sample form shows the OnClick event handler for the Switch to New Customer View button:

    function btnSwitchNew::OnClick(eventObj)
{
   XDocument.View.SwitchView("New Customer")
}
  

Note  The name of the button used in the event handler declaration is determined by the value set for the Script ID box in the Button Properties dialog box.