|InfoPath Developer Reference|
Version Added: InfoPath 2003
expression An expression that returns a XDocument object.
|pEvent||Required||DocReturnEvent||An event object that is used during a Microsoft Office InfoPath 2007 load or submission event.|
This event handler allows users to cancel an operation.
If the ReturnStatus property of the DocReturnEvent object is set to False, InfoPath cancels the loading of the form. If an error occurs in the scripting code for the OnLoad event handler, InfoPath ignores it and relies on the ReturnStatus property of the DocReturnEvent object. If the ReturnStatus property is not explicitly set, the default value of True is used.
|When the OnLoad event occurs, the view is not initialized and the XSL Transformation (XSLT) used for the view is not yet loaded. The XDocument object is not added to the XDocuments collection until after the OnLoad event has occurred. However, the XDocument object is available during the OnLoad event.|
In the following example from the Sales Report sample form, the OnLoad event handler is used to determine whether the form has been digitally signed, and if it hasn't, to initialize some date values using a combination of scripting functions and custom functions:
This Onload event handler example depends on two custom functions: initializeNodeValue and setNodeValue.