Export (0) Print
Expand All

FormEvents.Sign Event

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

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Exception typeCondition

InvalidOperationException

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

SecurityException

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

ImportantImportant:

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 Office InfoPath 2007 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, click Form Options on the Tools menu in the InfoPath design window, 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 as 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 Office InfoPath 2007.

In the following example, created by adding an event handler for the Sign event to the form by selecting Programming from the Tools menu 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;
}

Community Additions

Show:
© 2014 Microsoft