Skip to content

Instantly share code, notes, and snippets.

@5up3rman
Created July 13, 2017 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5up3rman/21c1066c9f9ad370f0bf86593e878e08 to your computer and use it in GitHub Desktop.
Save 5up3rman/21c1066c9f9ad370f0bf86593e878e08 to your computer and use it in GitHub Desktop.
Render Assets Control
using Sitecore.Web.UI;
using System.Collections.Generic;
using System.IO;
using System.Web.UI;
namespace EditorEnhancementToolkit.Foundation.ContentEditor.Pipelines.RenderPageAssets
{
public class RenderAssetsControl : WebControl
{
public List<string> StylesheetList { get; set; } = new List<string>();
protected override void DoRender(HtmlTextWriter output)
{
using (var stringWriter = new StringWriter())
{
var htmlTextWriter = new HtmlTextWriter(stringWriter);
foreach (var path in StylesheetList)
{
htmlTextWriter.Write(" ");
htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Href, path);
htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
htmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Link);
htmlTextWriter.RenderEndTag();
htmlTextWriter.WriteLine();
}
output.Write(stringWriter.ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment