Microsoft Office Tutorials and References
In Depth Information
Form-level events
if (Validate() == true)
{
string xPath = "/my:myFields/my:MyAge";
XPathNavigator xNavigator = MainDataSource.CreateNavigator();
XPathNavigator xValueNavigator = xNavigator.
SelectSingleNode(xPath, NamespaceManager);
FileSubmitConnection xConnection = (FileSubmitConnection)(
DataConnections["DataSource"]); xConnection.
Execute(xValueNavigator);
}
else
{
MessageBox.Show("Please fill the form correctly");
}
}
Using the VersionUpgrade event
The VersionUpgrade events are not available from third-party hosted applications
because these events occur before the form is loaded in the hosted application.
FormEvents_VersionUpgrade(object sender, VersionUpgradeEventArgs e)
This event is triggered when the version number of the form being opened is
older than the version number of the form template on which it is based. Here's
an example:
public void FormEvents_VersionUpgrade(object sender,
VersionUpgradeEventArgs e)
{
// Version details displayed in Message box
MessageBox.Show("InfoPath Form Version: " + e.DocumentVersion +
"\n InfoPath Form Template Version: " +
e.FormTemplateVersion);
}
The VersionUpgrade event can be cancelled by using the CancelableArgs property
of the VersionUpgradeEventArgs class to set the Cancel property to true .
Using the Save event
The Save event is not meant to be instantiated by the developer in form code. You
can add event handlers for form-level events via the Microsoft Office InfoPath 2007
Design mode user interface.
FormEvents_Save(object sender, SaveEventArgs e)
 
Search JabSto ::




Custom Search