Text
Contents
[
Hide
]FieldSubject.Text property
Gets or sets the text of the subject.
public string Text { get; set; }
Examples
Shows how to use the SUBJECT field.
Document doc = new Document();
// Set a value for the document's "Subject" built-in property.
doc.BuiltInDocumentProperties.Subject = "My subject";
// Create a SUBJECT field to display the value of that built-in property.
DocumentBuilder builder = new DocumentBuilder(doc);
FieldSubject field = (FieldSubject)builder.InsertField(FieldType.FieldSubject, true);
field.Update();
Assert.That(field.GetFieldCode(), Is.EqualTo(" SUBJECT "));
Assert.That(field.Result, Is.EqualTo("My subject"));
// If we give the SUBJECT field's Text property value and update it, the field will
// overwrite the current value of the "Subject" built-in property with the value of its Text property,
// and then display the new value.
field.Text = "My new subject";
field.Update();
Assert.That(field.GetFieldCode(), Is.EqualTo(" SUBJECT \"My new subject\""));
Assert.That(field.Result, Is.EqualTo("My new subject"));
Assert.That(doc.BuiltInDocumentProperties.Subject, Is.EqualTo("My new subject"));
doc.Save(ArtifactsDir + "Field.SUBJECT.docx");
See Also
- class FieldSubject
- namespace Aspose.Words.Fields
- assembly Aspose.Words