Partager via


SubmitToHostConnection Class

Represents a connection for submitting data to a hosting environment.

Inheritance Hierarchy

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

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

Syntax

'Declaration
Public MustInherit Class SubmitToHostConnection _
    Inherits DataConnection
'Usage
Dim instance As SubmitToHostConnection
public abstract class SubmitToHostConnection : DataConnection

Remarks

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.

Examples

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

Thread Safety

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

See Also

Reference

SubmitToHostConnection Members

Microsoft.Office.InfoPath Namespace