Stylesheet Settings

Stylesheet Settings

Stylesheet Settings

  • The Webstylesheet configuration setting identifies the CSS file for HTML content of the Sitecore database
  • The specified file is automatically included in Html and Rich Text fields. You can make the content of Rich Text fields look the same as the actual Web Site
  • The WebEdit.ContentEditorStylesheet setting is the stylesheet to include in the Content Editor in WebEdit mode. Default value: /webedit.css
  • To register a custom external stylesheet, add an entry similar to the following to the head section of your layout (.aspx) file:

    <link href="/CSS/mystyles.css" rel="stylesheet"/>

Stylesheet Settings Configuration

  • <configuration>
    • <sitecore>
      • <settings>
        • <setting name="WebStylesheet" value="/default.css" />
        • <setting name="WebEdit.ContentEditorStylesheet" value="/webedit.css" />

Stylesheet Settings C# Web Control Code

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

string webStylesheet = Sitecore.Configuration.Settings.WebStylesheet;
string ContentEditorStylesheet = Sitecore.Configuration.Settings.WebEdit.ContentEditorStylesheet;

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 &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Web Stylesheet", "<b>" + webStylesheet + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Content Editor Stylesheet", "<b>" + ContentEditorStylesheet + "</b>");

output.RenderEndTag(); //Div


Stylesheet Settings C# Web Control Output

Web Stylesheet: /default.css
Content Editor Stylesheet: /webedit.css