惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 猫猫

SignalR 2.0 初次使用说明 解决VS2012上面EF字段说明备注没有的方法 生产百万级随机数 (转帖)C#批量重命名文件代码的实现 MyClipse DataBase Explorer 连接 ACCESS 配置说明 一个文本处理小工具(原创) C# 算法之 冒泡排序 实现数组转换为DataTable TreeView 部署到服务器上无法显示图标(失效) 仿google的suggest C# 把网页内容转为EXCEL,WORD C# 生产新闻文章分页 C# 实现页面3秒后跳转 正则表达式30分钟入门教程 转 正则表达式之道 转 正则表达式基础知识 转 常用正则表式 转 转 正则表达式教程 正则表达式教程 (转)
ASPNET动态生成静态页面
猫猫 · 2008-04-09 · via 博客园 - 猫猫

1.定义(template.htm)html模板页面

<html> 
<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" bgcolor="#eeeeee" style="border:1px solid #000000"> 
<tr> 
<td width="100%" valign="middle" align="left"> 
<span style="color: $htmlformat[1];font-size: $htmlformat[2]">$htmlformat[3]</span> 
</td> 
</tr> 
</table> 
</body> 
</html> 

2.asp.net代码:

//---------------------读html模板页面到stringbuilder对象里---- 

string[] format=new string[4];//定义和htmlyem标记数目一致的数组 
StringBuilder htmltext=new StringBuilder(); 
try 

 
using (StreamReader sr = new StreamReader("存放模板页面的路径和页面名")) 
 

  String line; 
  
while ((line = sr.ReadLine()) != null
  

   htmltext.Append(line); 
  }
 
  sr.Close(); 
 }
 
}
 
catch 

 Response.Write(
"<Script>alert('读取文件错误')</Script>"); 
}
 

//---------------------给标记数组赋值------------ 

format[
0]="background=\"bg.jpg\"";//背景图片 
format[1]= "#990099";//字体颜色 
format[2]="150px";//字体大小 
format[3]= "<marquee>生成的模板html页面</marquee>";//文字说明 
//----------替换htm里的标记为你想加的内容 
for(int i=0;i<4;i++

 htmltext.Replace(
"$htmlformat["+i+"]",format[i]); 
}
 

//----------生成htm文件------------------―― 

try 

 
using(StreamWriter sw=new StreamWriter("存放路径和页面名",false,System.Text.Encoding.GetEncoding("GB2312"))) 
 

  sw.WriteLine(htmltext); 
  sw.Flush(); 
  sw.Close(); 
 }
 
}
 
catch 

 Response.Write (
"The file could not be wirte:"); 
}