去除页面垃圾代码


    protected override void Render(HtmlTextWriter writer)

    {

        StringWriter sw = new StringWriter();

        HtmlTextWriter htmlWriter = new HtmlTextWriter(sw);

        base.Render(htmlWriter);

        string html = sw.ToString();

        html = Regex.Replace(html, "[\f\n\r\t\v]", "");

        html = Regex.Replace(html, " {2,}", " ");

        html = Regex.Replace(html, ">[ ]{1}", ">");

        writer.Write(html);

    }

你可能感兴趣的:(代码)