国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
ASP.NET 中如何對(duì)生成的 HTML 內(nèi)容流進(jìn)行控制? How to modify a...

在進(jìn)行 ASP.NET 開發(fā)時(shí),有時(shí)候需要對(duì)頁(yè)面輸出的最終 HTML 源代碼進(jìn)行控制,是頁(yè)面的 render 方法中很容易實(shí)現(xiàn)這個(gè)功能。下面就是一個(gè)實(shí)現(xiàn)的方法,注釋都在代碼中。

ASPX 代碼
<%@ Page Language="C#" %>

<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  protected override
void Render(HtmlTextWriter writer)
  {
    string content
= string.Empty;
    StringWriter stringWriter
= new StringWriter();
    HtmlTextWriter htmlWriter
= new HtmlTextWriter(stringWriter);
    
try
    {
      
// 將當(dāng)前頁(yè)面的內(nèi)容呈現(xiàn)到臨時(shí)的 HtmlTextWriter 對(duì)象中
      base.Render(htmlWriter);
      htmlWriter.Close();

      
// 得到當(dāng)前頁(yè)面的全部?jī)?nèi)容
      content = stringWriter.ToString();

      
// 替換頁(yè)面中的部分內(nèi)容
      string newContent = content.Replace("[mxh]", "孟憲會(huì)");

      
// 將新頁(yè)面的內(nèi)容顯示出來(lái)
      writer.Write(newContent);
    }
    
catch { }
    
finally
    {
      stringWriter.Dispose();
      htmlWriter.Close();
      htmlWriter.Dispose();
    }
  }

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  
<title>孟憲會(huì)之替換頁(yè)面呈現(xiàn)內(nèi)容測(cè)試</title>
</head>
<body>
  
<form id="form1" runat="server">
  [mxh]
  
</form>
</body>
</html>

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
asp.net頁(yè)面靜態(tài)化
asp.net控件開發(fā)基礎(chǔ)(2)
在ASP.NET 2.0中直接得到本頁(yè)面生成的HTML代碼vb
.NET 2.0中直接得到頁(yè)面HTML代碼(. NET 2.0 code in the H...
ASP.NET2.0中themes、Skins輕松實(shí)現(xiàn)網(wǎng)站換膚! - BearRui(AK...
ASP.NET Web 頁(yè)面語(yǔ)法概覽
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服