DataDOMEventObject interface

An event object that is used during Microsoft InfoPath data validation events.

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

Syntax

'Declaration
<GuidAttribute("096cd5e5-0786-11d1-95fa-0080c78ee3bb")> _
Public Interface DataDOMEventObject _
    Inherits DataDOMEvent, DocActionEvent, DocReturnEvent, DocEvent
'Usage
Dim instance As DataDOMEventObject
[GuidAttribute("096cd5e5-0786-11d1-95fa-0080c78ee3bb")]
public interface DataDOMEventObject : DataDOMEvent, 
    DocActionEvent, DocReturnEvent, DocEvent

Remarks

This type is a wrapper for a coclass that is required by managed code for COM interoperability. Use this type to access the members of the COM interface implemented by this coclass. For information about the COM interface, including a link to descriptions of its members, seeDataDOMEvent.

The DataDOMEvent object provides a number of properties and a method that can be used within a data validation event to programmatically interact with the data that is being validated and to provide a response if the data is not valid.

The DataDOMEvent object is passed as a parameter to the OnBeforeChange, the OnValidate, and the OnAfterChange events

Note

The OnValidate event can occur without a change in the form's underlying XML document.

The DataDOMEvent object is used to get information about the XML Document Object Model (DOM) node that is being changed, and it also provides a property for getting a reference to a form's underlying XML document. In addition, it provides properties for handling the change in data, including rejecting the change and creating an error message.

Note

The DataDOMEvent object is passed as an argument to one of the data validation event handlers. Its properties and method are only available during the event that it is passed to.

Examples

In the following example, the DataDOMEvent object is used to check the value of the node using the Site property. If the data validation fails, the ReportError method is used to create a custom error.

[InfoPathEventHandler(MatchPath="/my:myFields/my:field1", EventType=InfoPathEventType.OnValidate)]
public void field1_OnValidate(DataDOMEvent e)
{
if(e.Site.text != "")
{
   int quantity = int.Parse(e.Site.text.ToString());
   if(quantity > 50)
   {
      e.ReportError(e.Site, "Invalid quantity. The total number of each type of block cannot exceed 50.", false, "", 2,"modeless");
  }
   if(quantity < 0)
   {
      e.ReportError(e.Site, "Invalid quantity. The total number of each type of block cannot be less than 0.", false,"", 2,"modeless");
   }
}
}

See also

Reference

DataDOMEventObject members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace