DataDOMEvent.ReportError method

Creates an ErrorObject object and adds it to the ErrorsCollection collection.

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

Syntax

'Declaration
Function ReportError ( _
    varNode As Object, _
    bstrShortErrorMessage As String, _
    fSiteIndependent As Boolean, _
    bstrDetailedErrorMessage As String, _
    lErrorCode As Integer, _
    bstrType As String _
) As ErrorObject
'Usage
Dim instance As DataDOMEvent
Dim varNode As Object
Dim bstrShortErrorMessage As String
Dim fSiteIndependent As Boolean
Dim bstrDetailedErrorMessage As String
Dim lErrorCode As Integer
Dim bstrType As String
Dim returnValue As ErrorObject

returnValue = instance.ReportError(varNode, _
    bstrShortErrorMessage, fSiteIndependent, _
    bstrDetailedErrorMessage, lErrorCode, _
    bstrType)
ErrorObject ReportError(
    Object varNode,
    string bstrShortErrorMessage,
    bool fSiteIndependent,
    string bstrDetailedErrorMessage,
    int lErrorCode,
    string bstrType
)

Parameters

  • varNode
    Type: System.Object

    The XML Document Object Model (DOM) node that the error is associated with.

  • bstrShortErrorMessage
    Type: System.String

    The text to be used for the short error message.

  • fSiteIndependent
    Type: System.Boolean

    Sets the condition for automatic deletion of the Error object. If true, the Error object will be deleted on change for any nodes that matched the XPath expression corresponding to the Error object. If false, the Error object will be deleted when the node returned by the Site property of a given event object has been changed.

  • bstrDetailedErrorMessage
    Type: System.String

    The text to be used for the detailed error message.

  • lErrorCode
    Type: System.Int32

    The number to be used as the error code.

  • bstrType
    Type: System.String

    Default value is "modeless". Determines whether the change in value will be automatically rejected or whether the user will be prompted to accept or reject the change. The other value is "modal".

Return value

Type: Microsoft.Office.Interop.InfoPath.SemiTrust.ErrorObject
The ErrorObject object representing the newly created Error.

Remarks

When the ReportError method is called, Microsoft InfoPath creates an Error object and adds it to the Errors collection. Errors are removed from the collection when the validation constraint is no longer invalid. In certain cases they can be explicitly removed using the Delete or DeleteAll methods.

Errors can also be created using the Add method.

Note

Site-independent errors should be used when you want the errors to apply to all XML DOM nodes of the same type. If you want the error to apply to a specific XML DOM node, use site-dependent errors.

Note

The ReportError method can only be used during the OnValidate event.

Important

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Examples

In the following example, the Site property of the DataDOMEventObject object is used to check the value of the node. 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 (int.Parse(e.Site.text) > 50)
 {
  e.ReportError(
   e.Site, 
   "Invalid quantity. The total number of each type of block cannot exceed 50.", 
   false,
   "",
   2,
   "modeless");
 }

 if (int.Parse(e.Site.text) < 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

DataDOMEvent interface

DataDOMEvent members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace