欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.net輸出重寫壓縮頁(yè)面文件的小例子

 更新時(shí)間:2013年07月24日 11:40:54   作者:  
這篇文章介紹了.net輸出重寫壓縮頁(yè)面文件的小例子,有需要的朋友可以參考一下

不知你是否留意過(guò),有一些網(wǎng)站的html代碼都是混在一起,沒(méi)有任何空格和換行等多余字符。它的好處不用多說(shuō)——界面大小絕對(duì)優(yōu)化?;蛟S您在想,他們這樣做大大降低了可讀性。的確,我們看是很亂,只能借用第三方軟件重新布局代碼。但是,我想他們開(kāi)發(fā)時(shí)使用的源碼不可能是混一團(tuán),前不久發(fā)現(xiàn)一個(gè)頁(yè)面基類,大概可以解釋這個(gè)問(wèn)題,不多說(shuō),看源碼:

復(fù)制代碼 代碼如下:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.htmlControls;
using System.Text.RegularExpressions;
using System.IO;

/// <summary>
/// PageBase 頁(yè)面基類
/// </summary>
public class PageBase : System.Web.UI.Page
{
    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 v]“, “”);
        html = Regex.Replace(html, ” {2,}”, ” “);
        html = Regex.Replace(html, “>[ ]{1}”, “>”);
        writer.Write(html);
    }
}

相關(guān)文章

最新評(píng)論