FieldSubjectText Property

Gets or sets the text of the subject.

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


public string Text { get; set; }

Property Value

Type: String


Shows how to use the SUBJECT field.
Document doc = new Document();

// Set a value for the document's subject property
doc.BuiltInDocumentProperties.Subject = "My subject";

// We can display this value with a SUBJECT field
DocumentBuilder builder = new DocumentBuilder(doc);
FieldSubject field = (FieldSubject)builder.InsertField(FieldType.FieldSubject, true);

Assert.AreEqual(" SUBJECT ", field.GetFieldCode());
Assert.AreEqual("My subject", field.Result);

// We can also set the field's Text attribute to override the current value of the Subject property
field.Text = "My new subject";

Assert.AreEqual(" SUBJECT  \"My new subject\"", field.GetFieldCode());
Assert.AreEqual("My new subject", field.Result);

// As well as displaying a new value in our field, we also changed the value of the document property
Assert.AreEqual("My new subject", doc.BuiltInDocumentProperties.Subject);

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

See Also