Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FormErrorCollection.Add Method (XPathNavigator, String, String)

Creates and adds a new FormError to the FormErrorCollection object associated with the current form.

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

Parameters

context

An XPathNavigator object positioned at the node that the error will be associated with.

name

The name of the error (cannot be blank).

message

The short message for the error.

Return Value

A reference to the new FormError that was added to the collection.

Exception typeCondition

ArgumentNullException

The parameters passed to this method are null.

ArgumentException

The parameters passed to this method arenot valid. For example, they are of the wrong type or format.

The FormErrorType of the new FormError will be set to UserDefined.

NoteNote:

It is possible to add multiple errors with the same name parameter value to different context nodes. However, if you add an error with the same name to the same context node twice, the second error added overwrites the first one.

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.

This type or member can be accessed from code running in forms opened in Microsoft Office InfoPath 2007 or in a Web browser.

In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator, name, and message are passed to the Add method of the FormErrorCollection class to add the error to the form's error collection.

XPathNavigator root, txtbox;
// Create XPathNavigator for main data source.
root = this.MainDataSource.CreateNavigator();

// Create XPathNavigator positioned at field to associate with error.
txtbox = root.SelectSingleNode("//my:field1", this.NamespaceManager);

// Get form's collection of errors and add error.
this.Errors.Add(txtbox, "Field1Error", "Short error message.");

Community Additions

Show:
© 2015 Microsoft