Edit

Share via


FormEvents.Sign Event

Definition

Occurs after a set of signed data has been selected to sign through the Digital Signatures dialog box.

public:
 abstract event Microsoft::Office::InfoPath::SignEventHandler ^ Sign;
public abstract event Microsoft.Office.InfoPath.SignEventHandler Sign;
member this.Sign : Microsoft.Office.InfoPath.SignEventHandler 
Public MustOverride Custom Event Sign As SignEventHandler 

Event Type

Exceptions

The developer attempted to bind the event in some location other than the InternalStartup method.

The form template is not configured for Full Trust using the Security and Trust category of the Form Options dialog box.

Examples

In the following example, created by adding an event handler for the Sign event to the form by clicking Sign Event on the Developer tab in the InfoPath design mode user interface, a digital signature is added to the form by using the Sign() method of the Signature class.

public void FormEvents_Sign(object sender, SignEventArgs e)
{
   // This event handler will run only in fully trusted form templates.

   Signature thisSignature = 
     e.SignedDataBlock.Signatures.CreateSignature();

   // To add other pieces of information to sign, modify the
   // signature template returned by 
   // thisSignature.SignatureBlockXmlNode.
   // Write your code here.

   thisSignature.Sign();
   e.SignatureWizard = false;
}
Public Sub FormEvents_Sign(ByVal sender As Object, _
   ByVal e As SignEventArgs)
   ' This event handler will run only in fully trusted form templates.

   Dim thisSignature As Signature = _
     e.SignedDataBlock.Signatures.CreateSignature

   ' To add other pieces of information to sign, modify the
   ' signature template returned by 
   ' thisSignature.SignatureBlockXmlNode.
   ' Write your code here.

   thisSignature.Sign()
   e.SignatureWizard = False
}

Remarks

Important: The Sign event is not meant to be instantiated by the developer in form code. You should only add event handlers for form-level events from the Microsoft InfoPath design mode user interface. When you add an event handler to your form template from the design mode user interface, InfoPath generates code in the InternalStartup method of your form code file using the EventManager class and the member of the FormEvents class to bind the event to its event handler. For information on how to add event handlers in InfoPath design mode, see How to: Add an Event Handler.

The Sign event is bound using the SignEventHandler delegate.

An event handler for this event requires the Full Trust security level to run. To set this security level, in the InfoPath designer click the File tab, click Form Options, select Security and Trust, uncheck Automatically determine security level, and then select Full Trust. A form set to the Full Trust security level must be installed or digitally signed.

You can use the event handler for the Sign event to add additional data to the digital signature. For example, you can add data from a trusted timestamp server, or add a server-side countersignature of the transaction. You can also use the event handler to block signing if the current user is not a member of a particular group.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

Applies to