protected void ProtectControls(HtmlTextWriter output, ControlCollection controls) { foreach (Control ctl in controls) { if (ctl.GetType().FullName == "System.Web.UI.LiteralControl" || ctl.GetType().FullName == "System.Web.UI.ResourceBasedLiteralControl") { string text = ((LiteralControl)ctl).Text; if (_removeLineFeeds) { text = text.Replace("\n", "").Replace("\r\n", ""); } //output.Write((Page.Request.Browser.Crawler ? text : HtmlProtector.HtmlEncrypt(text))); output.Write(HtmlProtector.HtmlEncrypt(text)); } else { System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter textWriter = new HtmlTextWriter(sw); ctl.RenderControl(textWriter); //output.Write((Page.Request.Browser.Crawler ? textWriter.InnerWriter.ToString() : HtmlProtector.HtmlEncrypt(textWriter.InnerWriter.ToString()))); output.Write(HtmlProtector.HtmlEncrypt(textWriter.InnerWriter.ToString())); //ctl.RenderControl(output); } /*if (ctl.Controls.Count > 0) * { * ProtectControls(output,ctl.Controls); * }*/ } }
/// <summary> /// Gets the design time HTML code. /// </summary> /// <returns>A string containing the HTML to render.</returns> public override string GetDesignTimeHtml() { HtmlProtector protector = (HtmlProtector)base.Component; StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(stringWriter); writer.Write("[HtmlProtector \"{0}\"]", protector.ClientID); return(stringWriter.ToString()); }