我用。net做了个新闻发布系统,请问如何把这个做成静态页啊?
解决方案 »
- 循环输出的问题
- 急。用过EXT或懂得JsonReader用的进来帮帮小弟
- 为什么总是发布失败
- 如何动太添加多个主键到GridView1!
- 如何实现商务网站的相关新闻功能?
- System.Security.SecurityException: 不允许所请求的注册表访问权
- 调试无错误信息,但是在IE中GridView控件显示不出来
- 菜鸟学飞,问一个简单的DropDownList问题,各位大哥多多关照
- 我做的无闪烁关联下拉列表更新控件,支持可视化设计,欢迎下载并反馈
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 求一个替换掉特殊字符的正则表达式
- 读取网页的标题和内容,如何实现?
- 关于ONUNLOAD
先读取模板页中的内容并保存在一个string变量中,然后进行替换,把刚前面说的那些占位字符替换成你的想要的内容,最后进行写文件操作保存文件(后缀为.html的)
private void newspage()
{
string[,] list = new string[,]{
{"financialtimes", "Financial Times"},
{"bbcnews", "BBC News"},
{"cepnews", "CEP News"},
{"actionforex", "ActionForex.com"},
{"fxstreet", "FX Street"},
{"fx360", "FX360.com"},
{"dailyfx", "Daily FX"},
{"moreover", "Moreover"},
}; int n = list.GetLength(0);
StringBuilder body = new StringBuilder(5000);
string str;
string path = System.AppDomain.CurrentDomain.BaseDirectory + "news/news2.htm"; //取网站虚拟目录的实际文件夹
using (StreamReader sr = File.OpenText(path))
{
str = sr.ReadToEnd();
for (int i = 0; i < n; i++)
{
body.Remove(0, body.Length);
DataRow[] rows = dtNews.Select("publisher='" + list[i, 1] + "'", "tim DESC");
int m = rows.GetLength(0);
for (int j = 0; j < m; j++)
{
DataRow row = rows[j];
body.AppendFormat("<div class='nstyle1'>" +
"<div class='nstyle2'>{0:yyMMdd HHmmss}</div> <a href=\"javascript:showdescriptionl('id{6}_{5}')\">{1}</a></div>" +
"<div id='id{6}_{5}' class='style100'><br><a class='s14' href='../LinkOut.htm?FROM=homepage&URL={2}' target='_blank'>STORY LINK</a> <span class='s14 red'>{4}</span><br><br>{3}</div>",
row[1], row[2], row[3], Components.comm.txtTOhtm(row[4].ToString()), row[0], j, i
);
}
str = str.Replace("<hhhh:" + list[i, 0] + " />", body.ToString());
}
}
path = System.AppDomain.CurrentDomain.BaseDirectory + "news/news.htm"; //取网站虚拟目录的实际文件夹
using (StreamWriter sw = File.CreateText(path)) //?? 能不能打开一次文件,完成读和写。
{
sw.Write(str);
}
}
伪静态的也没有什么意义,
比较合理的方法是用ajax+ashx,前台是正真的html,不过目前不太成熟,例子也不多。