Monday, 26 December 2011
Thursday, 1 December 2011
Remove whitespace from HTML
private static readonly Regex RegexBetweenTags = new Regex(@">(?! )\s+", RegexOptions.Compiled);
private static readonly Regex RegexLineBreaks = new Regex(@"([\n\s])+?(?<= {2,})<", RegexOptions.Compiled);
-----------------------------
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
{
base.Render(htmlwriter);
string html = htmlwriter.InnerWriter.ToString();
writer.Write(RemoveWhitespaceFromHtml(html));
}
}
public static string RemoveWhitespaceFromHtml(string html)
{
html = RegexBetweenTags.Replace(html, ">");
html = RegexLineBreaks.Replace(html, "<");
return html.Trim();
}
Subscribe to:
Posts (Atom)
Get all non-clustered indexes
DECLARE cIX CURSOR FOR SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID FROM Sys.Indexes SI ...
-
DECLARE @tablas TABLE(tableName nvarchar(100)) INSERT INTO @tablas SELECT t.TABLE_SCHEMA+ '.'+t.TABLE_NAME FROM INFORMATION_SCHEMA...
-
In C# using System; using System.Collections.Generic; using System.Linq; using System.Web; public class encode_decode { public ...
-
Design page ------------ <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inheri...