MultiLine Properties

MultiLine Properties

Multi-Line Text Fields

  • Store field values as raw text
  • Supported by <sc:text> web control in declarative markup
  • Field values can be displayed by the FieldRenderer.Render() method and FieldRenderer control
  • Natively supports displaying field values in the Page Editor

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Database
  • Sitecore.Data.Fields.TextField
  • Sitecore.Data.Items.Item
  • Sitecore.MainUtil

MultiLine Properties C# Web Control Code

//get Simple Fields metadata item from context database using item guid
Sitecore.Data.Database db = Sitecore.Context.Database;
Sitecore.Data.Items.Item item = db.GetItem("{EC44470F-FF45-4023-95C2-EC886FD33D0C}");
if (item == null) return;

Sitecore.Data.Fields.TextField mltFld = item.Fields["example multi-line text"];
if (mltFld == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Field", mltFld.InnerField.DisplayName);
output.RenderEndTag(); //P

output.Write("Can Read? " + "<b>" + mltFld.InnerField.CanRead.ToString() + "</b><br/>"); 
output.Write("Can Write? " + "<b>" + mltFld.InnerField.CanWrite.ToString() + "</b><br/>"); 
output.Write("Contains Standard Value? " + "<b>" + mltFld.InnerField.ContainsStandardValue.ToString() + "</b><br/>"); 
output.Write("Definition: " + "<b>" + mltFld.InnerField.Definition.Name + "</b><br/>"); 
output.Write("Description: " + "<b>" + mltFld.InnerField.Description + "</b><br/>"); 
output.Write("Display Name: " + "<b>" + mltFld.InnerField.DisplayName + "</b><br/>"); 
output.Write("Has Blob Stream? " + "<b>" + mltFld.InnerField.HasBlobStream.ToString() + "</b><br/>"); 
output.Write("Has Value? " + "<b>" + mltFld.InnerField.HasValue.ToString() + "</b><br/>"); 
output.Write("ID: " + "<b>" + mltFld.InnerField.ID.ToString() + "</b><br/>"); 
output.Write("Contains Inherited Value? " + "<b>" + mltFld.InnerField.InheritedValue + "</b><br/>"); 
output.Write("Is Blob Field? " + "<b>" + mltFld.InnerField.IsBlobField.ToString() + "</b><br/>"); 
output.Write("Has Been Modified? " + "<b>" + mltFld.InnerField.IsModified.ToString() + "</b><br/>"); 
output.Write("Key: " + "<b>" + mltFld.InnerField.Key + "</b><br/>"); 
output.Write("Language: " + "<b>" + mltFld.InnerField.Language.Name + "</b><br/>"); 
output.Write("Name: " + "<b>" + mltFld.InnerField.Name + "</b><br/>"); 
output.Write("Reset Blank On? " + "<b>" + mltFld.InnerField.ResetBlank.ToString() + "</b><br/>"); 
output.Write("Section Name: " + "<b>" + mltFld.InnerField.Section + "</b><br/>"); 
output.Write("Sort Order: " + "<b>" + mltFld.InnerField.Sortorder.ToString() + "</b><br/>"); 
output.Write("Shared? " + "<b>" + mltFld.InnerField.Shared.ToString() + "</b><br/>"); 
output.Write("Source: " + "<b>" + mltFld.InnerField.Source + "</b><br/>"); 
output.Write("Title: " + "<b>" + mltFld.InnerField.Title + "</b><br/>"); 
output.Write("Tooltip: " + "<b>" + mltFld.InnerField.ToolTip + "</b><br/>"); 
output.Write("Translatable? " + "<b>" + mltFld.InnerField.Translatable.ToString() + "</b><br/>"); 
output.Write("Type: " + "<b>" + mltFld.InnerField.Type + "</b><br/>"); 
output.Write("Type Key: " + "<b>" + mltFld.InnerField.TypeKey + "</b><br/>"); 
output.Write("Unversioned? " + "<b>" + mltFld.InnerField.Unversioned.ToString() + "</b><br/>"); 
output.Write("Validation Regex: " + "<b>" + mltFld.InnerField.Validation + "</b><br/>"); 
output.Write("Validation Message: " + "<b>" + mltFld.InnerField.ValidationText + "</b><br/>"); 
output.Write("Value: " + "<b>" + mltFld.InnerField.Value + "</b>");

output.RenderEndTag(); //Div


MultiLine Properties C# Web Control Output

Can Read? True
Can Write? True
Contains Standard Value? True
Definition: Example Multi-Line Text
Description: 
Display Name: Example Multi-Line Text
Has Blob Stream? False
Has Value? False
ID: {9689E59B-25EA-4771-A2AF-B9549AE817EF}
Contains Inherited Value? This raw text cannot fit on a single line. The multi-line text field enables users to view the first few lines of the content immediately. Additional lines can be viewed by using the scroll bar.
Is Blob Field? False
Has Been Modified? False
Key: example multi-line text
Language: en
Name: Example Multi-Line Text
Reset Blank On? False
Section Name: Simple Field Types
Sort Order: 700
Shared? False
Source: 
Title: 
Tooltip: 
Translatable? False
Type: Multi-Line Text
Type Key: multi-line text
Unversioned? False
Validation Regex: 
Validation Message: 
Value: This raw text cannot fit on a single line. The multi-line text field enables users to view the first few lines of the content immediately. Additional lines can be viewed by using the scroll bar.