最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net實(shí)現(xiàn)生成靜態(tài)頁(yè)并添加鏈接的方法

 更新時(shí)間:2014年07月22日 15:07:33   投稿:shichen2014  
這篇文章主要介紹了asp.net實(shí)現(xiàn)生成靜態(tài)頁(yè)并添加鏈接的方法,非常實(shí)用的功能,需要的朋友可以參考下

本文以實(shí)例講解了asp.net實(shí)現(xiàn)生成靜態(tài)頁(yè)并添加鏈接的方法,非常實(shí)用的功能,通過(guò)本實(shí)例可以加深讀者對(duì)于asp.net下文件操作的認(rèn)識(shí)。

1.創(chuàng)建一個(gè)靜態(tài)網(wǎng)頁(yè)模板

<!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>模板網(wǎng)頁(yè)</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網(wǎng)頁(yè)后臺(tái)代碼中替換模板html頁(yè)中的標(biāo)記符

protected void Button1_Click(object sender, EventArgs e)
{
string[] format = new string[5];//定義和htmlyem標(biāo)記數(shù)目一致的數(shù)組
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();
//---------------------給標(biāo)記數(shù)組賦值------------
format[0] = "background=\"bg.jpg\"";//背景圖片
format[1] = TB_Title.Text;
format[2] = "#990099"; //字體顏色
format[3] = "60px";//文字大小
format[4] = TB_Content.Text;
//----------替換htm里的標(biāo)記為你想加的內(nèi)容
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>");
}

相關(guān)文章

最新評(píng)論

探索| 夏邑县| 合阳县| 江陵县| 汕尾市| 衡南县| 威宁| 阳新县| 密云县| 马山县| 滨州市| 河池市| 祁连县| 墨脱县| 金湖县| 杭州市| 长子县| 河东区| 安康市| 石阡县| 四会市| 海城市| 德清县| 冕宁县| 宜黄县| 集安市| 北票市| 佛坪县| 五华县| 望江县| 白城市| 沅陵县| 松溪县| 囊谦县| 双城市| 博湖县| 青州市| 山阴县| 滕州市| 伊宁县| 涞水县|