Last Update

Last Update

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • System.Text.RegularExpressions.Regex

Last Update C# Web Control Code

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

string lastUpdate = Sitecore.Context.Item.Statistics.Updated.ToString("MMM dd, yyyy");
string updatedBy = System.Text.RegularExpressions.Regex.Replace(Sitecore.Context.Item.Statistics.UpdatedBy, ".*\\\\(.*)", "$1");

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}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Last update", "<b>" + lastUpdate + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Update by", "<b>" + updatedBy + "</b>");

output.RenderEndTag(); //Div


Last Update C# Web Control Output

Last update: Apr 11, 2012
Update by: Anonymous

Sources