Domain Names

Domain Names

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Factory
  • Sitecore.Data.Items.Item

Domain Names C# Web Control Code

protected override void DoRender(System.Web.UI.HtmlTextWriter output)
        {
string[] domList = Sitecore.Configuration.Factory.GetDomainNames();
if (domList == null) return;

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == 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}", "Item", item.DisplayName);
output.RenderEndTag(); //P
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Ul);

foreach (string domName in domList)
{
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Li);
    
    output.Write("{0}&#58;&#160;{1}", "Domain", "<b>" + domName + "</b>");
    output.RenderEndTag();
}

output.RenderEndTag(); //Ul
output.RenderEndTag(); //Div


Domain Names C# Web Control Output

  • Domain: sitecore
  • Domain: extranet
  • Domain: demo
  • Domain: default