Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SubmitToHostConnection class

Represents a connection for submitting data to a hosting environment.

System.Object
  Microsoft.Office.InfoPath.DataConnection
    Microsoft.Office.InfoPath.SubmitToHostConnection

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
public abstract class SubmitToHostConnection : DataConnection

This type of connection is used in a form template that is opened by an application that is hosting the InfoPath form editing environment as a control. For information about hosting InfoPath as a control, including information on how to create a method to handle the event for submitting a form in your host application’s code, see the article titled Hosting the InfoPath Form Editing Environment in a Custom Windows Form Application on MSDN.

To create a data connection for submitting data to a hosting environment that can be referenced from business logic in a form template, use the Data Connections command on the Data tab of the ribbon. For information on how to create an event handler that will run when the Submit event is raised, see How to: Add an Event Handler.

The following example shows a pattern for writing code that will perform custom actions in a form template's business logic before the form is submitted.

public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
   // Get the data connection defined in the form template from the 
   // DataConnections collection and cast to the SubmitToHostConnection
   // type.
   SubmitToHostConnection submitConnection = 
      (SubmitToHostConnection)(DataConnections["MyHostConnection"]);

   // Write code here to do custom actions that are not 
   // supported by rules or other declarative settings.  

   // Execute the submit operation against the connection.
   submitConnection.Execute();

}

Public Sub FormEvents_Submit(ByVal sender As Object, _
   ByVal e As SubmitEventArg)
   ' Get the data connection defined in the form template from the
   ' DataConnections collection and cast to the SubmitToHostConnection
   ' type.
   Dim submitConnection As SubmitToHostConnection = _
      DirectCast(DataConnections("MyHostConnection"), _
      SubmitToHostConnection)

   ' Write code here to do custom actions that are not 
   ' supported by rules or other declarative settings.

   ' Execute the submit operation against the connection.
   submitConnection.Execute()
End Sub
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.