This Get Item

This Get Item


  • An addressable unit of content with a specific location in the Content Tree
  • Made up of fields
  • Always has an associated Data Template
  • Similar to an XML object or a database record, not a file
  • Can contain any number of languages
  • Each language version can contain any number of numeric versions
  • Not available as pages on the site when they only contain metadata or system information

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Data.Items.Item

Item C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (item == null) return;

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

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P  

output.Write("{0}&#63;&#160;{1}", "Item can be read", "<b>" + item.Access.CanRead().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can read in the current language", "<b>" + item.Access.CanReadLanguage().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can be written", "<b>" + item.Access.CanWrite().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can be written in the current language", "<b>" + item.Access.CanWriteLanguage().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can be renamed", "<b>" + item.Access.CanRename().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can be duplicated", "<b>" + item.Access.CanDuplicate().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can be deleted", "<b>" + item.Access.CanDelete().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can create children", "<b>" + item.Access.CanCreate().ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item can admin", "<b>" + item.Access.CanAdmin().ToString() + "</b>");

output.RenderEndTag(); //Div

Item C# Web Control Output

Item can be read? True
Item can read in the current language? True
Item can be written? True
Item can be written in the current language? True
Item can be renamed? True
Item can be duplicated? True
Item can be deleted? True
Item can create children? True
Item can admin? True