Created
July 13, 2017 20:19
-
-
Save 5up3rman/21c1066c9f9ad370f0bf86593e878e08 to your computer and use it in GitHub Desktop.
Render Assets Control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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