FieldTitleText Property

Gets or sets the text of the title.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string Text { get; set; }

Property Value

Type: String
Examples
Shows how to use the TITLE field.
Document doc = new Document();

// A TITLE field will display the value assigned to this variable
doc.BuiltInDocumentProperties.Title = "My Title";

// Insert a TITLE field using a document builder
DocumentBuilder builder = new DocumentBuilder(doc);
FieldTitle field = (FieldTitle)builder.InsertField(FieldType.FieldTitle, false);
field.Update();

Assert.AreEqual(" TITLE ", field.GetFieldCode());
Assert.AreEqual("My Title", field.Result);

builder.Writeln();

// Set the Text attribute to display a different value
field = (FieldTitle)builder.InsertField(FieldType.FieldTitle, false);
field.Text = "My New Title";
field.Update();

Assert.AreEqual(" TITLE  \"My New Title\"", field.GetFieldCode());
Assert.AreEqual("My New Title", field.Result);

// In doing that we've also changed the title in the document properties
Assert.AreEqual("My New Title", doc.BuiltInDocumentProperties.Title);

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.TITLE.docx");
See Also