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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 猫猫

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:"); 
}