XML Control Settings

XML Control Settings

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Configuration.Settings.XmlControls
  • Sitecore.Data.Items.Item
  • Sitecore.StringUtil

XML Control Settings C# Web Control Code

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

string xmlControlAspxFile = Sitecore.Configuration.Settings.XmlControlAspxFile;
string xmlControlExtension = Sitecore.Configuration.Settings.XmlControlExtension;
string throwException = Sitecore.Configuration.Settings.XmlControls.ThrowException.ToString();

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);
string displayName = Sitecore.StringUtil.GetString(item.DisplayName, item.Name);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", displayName);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Xml Control Aspx File", "<b>" + xmlControlAspxFile + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Xml Control Extension", "<b>" + xmlControlExtension + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Xml Control Throw Exception", "<b>" + throwException + "</b>");

output.RenderEndTag(); //Div


XML Control Settings C# Web Control Output

Xml Control Aspx File: /layouts/xmlcontrol.aspx
Xml Control Extension: xml
Xml Control Throw Exception: False

Notes

  • XML provides a set of rules for creating platform-independent data interchange formats that different applications use to share data

Sources