Documentation Center

Handling a Component text field

You can retrieve text fields in Components as normal strings in code.

Package example

// Retrieve the contents of the text field called Summary
// from the Component item in the package.
string summaryField = package.GetValue("Component.Fields.Summary");

// Write the contents of the metadata text field called Topic to the log.
log.Info(package.GetValue("Component.MetaData.Topic"));

Content Manager example

// Get the value of the Product field of a specific, known Component.
Component component = (Component) engine.GetSession().GetObject("tcm:15-72");
ItemFields fields = new ItemFields(component.Content, component.Schema);
if (fields.Contains("Product"))
{
	string productName = fields["Product"].ToString();
}