FieldDisplayResult Property

Gets the text that represents the displayed field result.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.2.0

ExpandedSyntax

public string DisplayResult { get; }

Property Value

Type: String

ExpandedRemarks

ExpandedExamples

Shows how to get the real text that a field displays in the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("This document was written by ");
FieldAuthor fieldAuthor = (FieldAuthor)builder.InsertField(FieldType.FieldAuthor, true);
fieldAuthor.AuthorName = "John Doe";

// We can use the DisplayResult property to verify what exact text
// a field would display in its place in the document.
Assert.AreEqual(string.Empty, fieldAuthor.DisplayResult);

// Fields do not maintain accurate result values in real-time. 
// To make sure our fields display accurate results at any given time,
// such as right before a save operation, we need to update them manually.
fieldAuthor.Update();

Assert.AreEqual("John Doe", fieldAuthor.DisplayResult);

doc.Save(ArtifactsDir + "Field.DisplayResult.docx");

ExpandedSee Also