Microsoft Office Tutorials and References
In Depth Information
Form-level events
The SaveEventArgs object, which is passed as a parameter to an event handler for
the Save event, provides properties and methods that can be used to get the form's
file name, determine the Save status, and perform the Save operation.
To add a custom Save event to the InfoPath Form template, follow these steps:
1. Open the Tools menu and click on Form Options .
2. In the Form Options dialog box, click on Open and Save category , select the
Save using custom code checkbox, and then click on Edit .
3. Click OK to close the Form Options dialog box, and then replace the contents
of the FormEvents_Save method with the following code sample:
public void FormEvents_Save(object sender, SaveEventArgs e)
// Read the node
string strBookName = MainDataSource.CreateNavigator().
// Check the BookName enetered in the textbox
if (strBookName == string.Empty)
// If textbox is empty, prompt message to user
e.CancelableArgs.Message = "Please enter the BookName to save
the Form";
e.CancelableArgs.Cancel = true;
// Open SaveAs dialog box
if (e.IsSaveAs)
SetSaveAsDialogFilename(strBookName + ".xml");
e.CancelableArgs.Cancel = false;
Search JabSto ::

Custom Search