Share via


DataDOMEvent.NewValue Property

Gets the value of an XML Document Object Model (DOM) node that is being updated or inserted during a data validation event.

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

Syntax

'Declaration
'Usage

Remarks

The NewValue property contains the value of the XML DOM node that will replace the existing value. To get the original value of the XML DOM node, use the OldValue property.

Example

In the following example, the OldValue property of the DataDOMEventObject object is used to display the original value of an XML DOM node, along with its NewValue:

thisXDocument.UI.Alert("Original value: " + e.OldValue.ToString() + "\nNew value: " + e.NewValue.ToString());

In the following example, the NewValue property of the DataDOMEvent is checked for a blank value. If not blank, the "FirstName" and "Lastname" fields are cleared.

 if (e.IsUndoRedo)
 {
  // An undo or redo operation has occurred and the DOM is read-only.
  return;
 }

 // A field change has occurred and the DOM is writable. Write code here to respond
 // to the changes.
 if (e.NewValue.ToString() == "")
 return;

 if (thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@FirstName").text != "")
thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@FirstName").text = "";

 if (thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@LastName").text != "")
thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Employees/@LastName").text = "";

See Also

Reference

DataDOMEvent Interface
DataDOMEvent Members
Microsoft.Office.Interop.InfoPath Namespace