Microsoft Office Tutorials and References
In Depth Information
XPathNavigator xData = xDoc.SelectSingleNode("/my:
// Check and remove the "nil" attribute
// Loading the current user's name into a string variable
string strLoggedInUserName = System.Environment.UserName;
// Assigning the user'sname to the field value
The Loading event can be cancelled by using the CancelableArgs property of the
SaveEventArgs class and then setting the Cancel property to "true" .
Using the ViewSwitched event
By using the InfoPath form's ViewSwitched event, you can sync to other form events
such as Save , Merge , and so on.
FormEvents_ViewSwitched(object sender, ViewSwitchedEventArgs e)
InfoPath Forms Services is a server technology that makes it possible for users to ill
out InfoPath forms in a web browser.
public void FormEvents_ViewSwitched(object sender,
// Messagebox will display the view name with custom message
MessageBox.Show("Currently loading the view named: " +
Using the ContextChanged event
The ContextChanged event occurs when the context node changes. The
ContextChanged event is not supported in browser-enabled forms. Browser-enabled
forms are designed in InfoPath and can be filled out either in InfoPath or in a web
browser. InfoPath browser-enabled forms are to be used for better performance and
scalability. In addition, note that the ContextChanged event is asynchronous—the
event is not activated on every change in the context node; instead, it is activated
after the application has stopped processing other events.
FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)