Name Value Properties

Name Value Properties

Name Value List Fields

  • Store field values as text in URL QueryString format
  • There is no web control for use in declarative markup
  • Not supported by FieldRenderer.Render() method or FieldRenderer control
  • Supported by Sitecore.Web.WebUtil class in Sitecore API
  • 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.LookupField
  • Sitecore.Data.Items.Item
  • Sitecore.MainUtil

Name Value Properties C# Web Control Code

//get List 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.LookupField nvlFld = item.Fields["example name value list"];
if (nvlFld == 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 : for colon and   for space
output.Write("{0}: {1}", "Field", nvlFld.InnerField.DisplayName);
output.RenderEndTag(); //P

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

output.RenderEndTag(); //Div


Name Value Properties C# Web Control Output

Can Read? True
Can Write? True
Contains Standard Value? True
Definition: Example Name Value List
Description: 
Display Name: Example Name Value List
Has Blob Stream? False
Has Value? False
ID: {E3A27648-EA3C-4099-83A8-FD0083ADA06A}
Contains Inherited Value? ContentManagement=1&ItemLocks=2&WorkflowItems=3
Is Blob Field? False
Has Been Modified? False
Key: example name value list
Language: en
Name: Example Name Value List
Reset Blank On? False
Section Name: List Fields
Sort Order: 500
Shared? False
Source: 
Title: 
Tooltip: 
Translatable? False
Type: Name Value List
Type Key: name value list
Unversioned? False
Validation Regex: 
Validation Message: 
Value: ContentManagement=1&ItemLocks=2&WorkflowItems=3