Microsoft Office Tutorials and References
In Depth Information
Form-level events
XPathNavigator xData = xDoc.SelectSingleNode("/my:
myFields/my:field1", this.NamespaceManager);
// Check and remove the "nil" attribute
if (xData.MoveToAttribute("nil",
"http://www.w3.org/2001/XMLSchema-instance"))
xData.DeleteSelf();
// Loading the current user's name into a string variable
string strLoggedInUserName = System.Environment.UserName;
// Assigning the user'sname to the field value
xData.SetValue(strLoggedInUserName);
}
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,
ViewSwitchedEventArgs e)
{
// Messagebox will display the view name with custom message
MessageBox.Show("Currently loading the view named: " +
this.CurrentView.ViewInfo.Name);
}
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)
 
Search JabSto ::




Custom Search