Droplist Properties

Droplist Properties

Droplist Fields

  • Store item name or display name of selected item as raw text
  • Supported by <sc:text> web control in declarative markup
  • The Source field is required and specifies an item path in the Content Tree so the system can display the child items in the droplist field
  • Not supported by FieldRenderer.Render() method or FieldRenderer control
  • Field supports use of Sitecore Query to filter on source property
  • Does not natively support 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

Droplist Properties C# Web Control Code

//get Link Fields metadata item from context database using item guid
Sitecore.Data.Database db = Sitecore.Context.Database;
Sitecore.Data.Items.Item item = db.GetItem("{7246223A-BFB0-41F9-8A91-1E7D931CDC43}");
if (item == null) return;
Sitecore.Data.Fields.TextField dlFld = item.Fields["example droplist"];
if (dlFld == 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}", "Item", item.DisplayName);
output.RenderEndTag(); //P

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

output.RenderEndTag(); //Div


Droplist Properties C# Web Control Output

Can Read? True
Can Write? True
Contains Standard Value? True
Definition: Example Droplist
Description: 
Display Name: Example Droplist
Has Blob Stream? False
Has Value? False
ID: {87DD2DAF-929C-4D37-A67E-9A512DC651EA}
Contains Inherited Value? ManagingContent
Is Blob Field? False
Has Been Modified? False
Key: example droplist
Language: en
Name: Example Droplist
Reset Blank On? False
Section Name: List Fields
Sort Order: 200
Shared? False
Source: /sitecore/content/Home/ContentAuthors/Content
Title: 
Tooltip: 
Translatable? False
Type: Droplist
Type Key: droplist
Unversioned? False
Validation Regex: 
Validation Message: 
Value: ManagingContent