婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp.net實現生成靜態頁并添加鏈接的方法

asp.net實現生成靜態頁并添加鏈接的方法

熱門標簽:百度地圖怎樣做地圖標注 征途美甲店地圖標注 昆明語音電銷機器人價格 浦發電話機器人提醒還款 太原400電話上門辦理 電銷語音機器人型號參數 騰訊地圖標注手機 柳州電銷機器人公司 400電話如何申請取消

本文以實例講解了asp.net實現生成靜態頁并添加鏈接的方法,非常實用的功能,通過本實例可以加深讀者對于asp.net下文件操作的認識。

1.創建一個靜態網頁模板

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
title>模板網頁/title>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
/head>
body>
table $htmlformat[0] height="100%" border="0" width="100%" cellpadding="10" cellspacing="0" gcolor="#eeeeee" style="border:1px solid #000000">
tr>
td width="100%" valign="middle" align="left">
h1>$htmlformat[1]/h1>
div style="color: $htmlformat[2];font-size: $htmlformat[3]">$htmlformat[4]/div>
/td>
/tr>
/table>
/body>
/html>

2.在asp.net網頁后臺代碼中替換模板html頁中的標記符

protected void Button1_Click(object sender, EventArgs e)
{
string[] format = new string[5];//定義和htmlyem標記數目一致的數組
StringBuilder htmltext = new StringBuilder();
string templatePath = Server.MapPath("~/html/Template.html");
StreamReader sr = new StreamReader(templatePath);
String line;
while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}
sr.Close();
//---------------------給標記數組賦值------------
format[0] = "background=\"bg.jpg\"";//背景圖片
format[1] = TB_Title.Text;
format[2] = "#990099"; //字體顏色
format[3] = "60px";//文字大小
format[4] = TB_Content.Text;
//----------替換htm里的標記為你想加的內容
for (int i = 0; i  5; i++)
{
htmltext.Replace("$htmlformat[" + i + "]", format[i]);
}
//----------生成htm文件------------------――
string newfile = Server.MapPath("~/html/"+TB_Title.Text+".html");
StreamWriter sw = new StreamWriter(newfile, false, System.Text.Encoding.GetEncoding("GB2312"));
sw.WriteLine(htmltext);
sw.Flush();
sw.Close();
string newhref="html/" rel="external nofollow" +TB_Title.Text+".html";
Response.Write("a href=\"" + newhref + "\">" + TB_Title.Text + "/a>");
}
您可能感興趣的文章:
  • asp.net中MVC借助Iframe實現無刷新上傳文件實例
  • asp.net在iframe中彈出信息并執行跳轉問題探討
  • ASP.NET頁面借助IFrame提交表單數據所遇到問題的解決方法分享
  • asp.net 文件上傳與刷新與asp.net頁面與iframe之間的數據傳輸
  • ASP.NET中使用IFRAME建立類Modal窗口
  • asp.net省市三級聯動的DropDownList+Ajax的三種框架(aspnet/Jquery/ExtJs)示例
  • asp.net 學習之路 項目整體框架簡單的搭建
  • asp.net GridView中超鏈接的使用(帶參數)
  • ASP.NET 鏈接 Access 數據庫路徑問題最終解決方案
  • ASP.NET中iframe框架點擊左邊頁面鏈接 右邊顯示鏈接頁面內容

標簽:天門 張家界 德陽 蘭州 新疆 白山 陽泉 江蘇

巨人網絡通訊聲明:本文標題《asp.net實現生成靜態頁并添加鏈接的方法》,本文關鍵詞  asp.net,實現,生成,靜態,頁,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp.net實現生成靜態頁并添加鏈接的方法》相關的同類信息!
  • 本頁收集關于asp.net實現生成靜態頁并添加鏈接的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 乌鲁木齐市| 连江县| 濮阳市| 吴江市| 常宁市| 盱眙县| 佛坪县| 富裕县| 巴里| 多伦县| 建阳市| 镇赉县| 寿宁县| 特克斯县| 兴文县| 灵台县| 常熟市| 宁晋县| 平原县| 拜泉县| 曲阳县| 临邑县| 沅陵县| 济宁市| 原平市| 万源市| 汕尾市| 漯河市| 海伦市| 加查县| 南岸区| 阿拉善右旗| 濮阳县| 攀枝花市| 奉化市| 安仁县| 米易县| 奎屯市| 上杭县| 平湖市| 资溪县|