_XDocumentEventSink2_Event.OnVersionUpgrade Event
Occurs when the version number of a Microsoft InfoPath 2010 form being opened is older than the version number of the form template on which it is based.
Namespace: Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly: Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)
Syntax
'Declaration
Event OnVersionUpgrade As _XDocumentEventSink2_OnVersionUpgradeEventHandler
'Usage
Dim instance As _XDocumentEventSink2_Event
Dim handler As _XDocumentEventSink2_OnVersionUpgradeEventHandler
AddHandler instance.OnVersionUpgrade, handler
event _XDocumentEventSink2_OnVersionUpgradeEventHandler OnVersionUpgrade
Remarks
This event handler allows users to cancel an operation.
During the OnVersionUpgrade event, the form's underlying XML document is placed in read-only mode, and it is not validated against the form's associated XML Schema. If the ReturnStatus property of the VersionUpgradeEventObject object is set to false, InfoPath cancels the opening of the form. If an error occurs in the scripting code for the OnVersionUpgrade event, InfoPath ignores it and relies on the ReturnStatus property of the VersionUpgradeEventObject object. If the ReturnStatus property is not explicitly set, the default value of true is used.
Note
If you create an event handler for the OnVersionUpgrade event of a form template, you must edit the form definition file (.xsf) to include the optional useScriptHandler element of the documentVersionUpgrade element before it will run.
Examples
In the following example, the DocumentVersion and SolutionVersion properties of the VersionUpgradeEventObject object are used to display the version numbers of the form and form template:
[InfoPathEventHandler(EventType=InfoPathEventType.OnVersionUpgrade)]
public void OnVersionUpgrade(VersionUpgradeEvent e)
{
thisXDocument.UI.Alert("The form version: " + e.DocumentVersion +
"\nThe form template version: " + e.SolutionVersion);
e.ReturnStatus = true;
}
See Also
Reference
_XDocumentEventSink2_Event Interface