- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
net生成静态页
CODE: //生成HTML页 public static bool WriteFile(string strText,string strContent,string strAuthor) { string path = HttpContext.Current.Server.MapPath(/news/); Encoding code = Encoding.GetEncoding(gb2312); // 读取模板文件 string temp = HttpContext.Current.Server.MapPath(/news/text.html); StreamReader sr=null; StreamWriter sw=null; string str=; try { sr = new StreamReader(temp, code); str = sr.ReadToEnd(); // 读取文件 } catch(Exception exp) { HttpContext.Current.Response.Write(exp.Message); HttpContext.Current.Response.End(); sr.Close(); } string htmlfilename=DateTime.Now.ToString(yyyyMMddHHmmss) .html; // 替换内容 // 这时,模板文件已经读入到名称为str的变量中了 str =str.Replace(ShowArticle,strText); //模板页中的ShowArticle str = str.Replace(biaoti,strText); str = str.Replace(content,strContent); str = str.Replace(author,strAuthor); // 写文件 try { sw = new StreamWriter(path htmlfilename , false, code); sw.Write(str); sw.Flush(); } catch(Exception ex) { HttpContext.Current.Response.Write(ex.Message); HttpContext.Current.Response.End(); } finally { sw.Close(); } return true; 此函数放在Conn.CS基类中了 在添加新闻的代码中引用 注:工程名为Hover if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString))) { Response.Write(添加成功); } else { Response.Write(生成HTML出错!); } 模板页Text.html代码 CODE: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTML HEAD titleShowArticle/title body biaoti br contentbr author /body /HTML biaoti br contentbr author /body /HTML
.Net生成静态页并实现分页效果
1、静态模板页面 template.html,主要是定义了一些特殊字符,用来被替换。
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN/TR/html4/loose.dtdhtmlheadmeta http-equiv=Content-Type content=text/html; charset=gb2312titleTitle/title/headbodydiv style=width: 417px; height: 54px align=centerbr /Title/divdiv style=width: 417px; height: 8px浏览font color=redscript src=http://localhost/.Net/NewsFiles/ClickCount.aspx?NewsId=NewsId/script/font次 Time/divdiv style=width
文档评论(0)