Last active
August 29, 2015 14:01
Revisions
-
falafelsoftware revised this gist
May 8, 2014 . No changes.There are no files selected for viewing
-
falafelsoftware created this gist
May 8, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Web.UI; using HtmlAgilityPack; using Telerik.Sitefinity.Configuration; namespace Sitefinity.Framework.Web.Controls { /// <summary> /// A base class that will be used for the master pages to remove the Telerik Web resource /// </summary> public class MasterBase : MasterPage { protected override void Render(HtmlTextWriter writer) { //Render normally in the backend or if the setting is false if (this.IsBackend() || this.IsDesignMode()) { base.Render(writer); return; } var tw = new StringWriter(); var htw = new HtmlTextWriter(tw); base.Render(htw); //Get page source var pageSource = tw.ToString(); //Load the html document to use HtmlAgilityPack var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(pageSource); if (htmlDoc.DocumentNode == null) return; //Get the telerik UI web resource scripts var bodyNode = htmlDoc.DocumentNode.SelectNodes("//script").Where(s => s.GetAttributeValue("src", string.Empty).Contains(Constants.TELERIK_WEBUI_WEBRESOURCE) || string.IsNullOrEmpty(s.GetAttributeValue("src", string.Empty))); foreach (var node in bodyNode) { //Delete the scripts if there is a match node.ParentNode.RemoveChild(node); } pageSource = htmlDoc.DocumentNode.OuterHtml; //render the outer html writer.Write(pageSource); } } }