EventManager class

Office 2013 and later

Used to initialize and bind event handlers in the InternalStartup method of a form template.


Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract class EventManager

The EventManager class is used by InfoPath to bind event handlers for all of the events implemented by the ControlEvents, FormEvents, and XmlEvents classes in the InternalStartup method at the beginning of the FormCode class in a managed code form template. At run time, the InternalStartup method is executed when the form template is opened to initialize the binding of all event handlers.


When a form template is opened in InfoPath, the InternalStartup method is called whenever a user opens the form template. Whereas, when a form template is opened in a Web browser from an appropriately configured document library on SharePoint Server 2010 running InfoPath Forms Services, the InternalStartup method is called only the first time the form template business logic assembly is loaded into an AppDomain on the server. This usually corresponds to the time the first user opens an instance of the form template during a session, or after the AppDomain is recycled during a session.

The following examples, show the InternalStartup method from a FormCode class (from the FormCode.cs or FormCode.vb files) of a form template that binds the event handlers for a form's Loading event, a field's Changed event, and a Button control's Clicked event using their corresponding delegates.

Important noteImportant

The InternalStartup method and the event binding code within it are generated by InfoPath when you add event handlers using various user interface commands. You should not create the InternalStartup method or write any additional code within it yourself. For information about how to add event handlers using interface commands, see How to: Add an Event Handler.

public void InternalStartup()
   EventManager.FormEvents.Loading += 
      new LoadingEventHandler(FormEvents_Loading);
   EventManager.XmlEvents["/my:myFields/my:Name"].Changed += 
      new XmlChangedEventHandler(Name_Changed);
   ((ButtonEvent)EventManager.ControlEvents["MyBtn"]).Clicked += 
      new ClickedEventHandler(MyBtn_Clicked);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.