婷婷综合国产,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實現生成靜態頁并添加鏈接的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 六安市| 广东省| 洪泽县| 调兵山市| 蚌埠市| 卓资县| 临湘市| 应城市| 瑞金市| 扎赉特旗| 临猗县| 汨罗市| 明溪县| 故城县| 德保县| 绥棱县| 内江市| 郁南县| 天镇县| 稻城县| 台山市| 安岳县| 西林县| 桃源县| 塘沽区| 腾冲县| 吴旗县| 界首市| 阿拉善左旗| 屏东市| 东阿县| 富阳市| 忻城县| 正阳县| 盱眙县| 阿尔山市| 长治市| 繁昌县| 简阳市| 周至县| 台湾省|