您好,欢迎光临本网站![请登录][注册会员]  
文件名称: WebSites 带分页静态生成
  所属分类: Web开发
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2009-07-21
  提 供 者: renso*****
 详细说明: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data; using System.Data.SqlClient; using System.IO; using System.Text; public partial class CreatePage : System.Web.UI.Page { Encoding gb = Encoding.GetEncoding("gb2312"); protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string str = LoadTemplate("PageTemplate.txt"); string ls1 = LoadNewsList(1); string ls2 = LoadNewsList(2); string ls3 = LoadNewsList(3); string pl1 = LoadPhotoList(1); string pl2 = LoadPhotoList(2); str=str.Replace("[--@title--]", "首页"); str=str.Replace("[--@NL1--]", ls1); str=str.Replace("[--@NL2--]", ls2); str=str.Replace("[--@NL3--]", ls3); str = str.Replace("[--@PL1--]", pl1); str = str.Replace("[--@PL2--]", pl2); SavePage("index.html", str); } public string LoadPhotoList(int CategoryID) { string temp = LoadTemplate("PhotoList.txt"); string sql = "select top 4 ProductID,ProductName from Products where CategoryID=" + CategoryID + " order by ProductID desc"; SqlDataReader dr = ConnDB.ExecuteReader(sql); string st=""; while (dr.Read()) { string str = ""; str=temp.Replace("[--@filename--]",dr[0].ToString()+".jpg"); str=str.Replace("[--@ID--]",dr[0].ToString()); str=str.Replace("[--@photoname--]",dr[1].ToString()); st += str; } return st; } public string LoadNewsList(int CategoryID) { string sql = "select top 8 ProductID,ProductName from Products where CategoryID=" + CategoryID + " order by ProductID desc"; SqlDataReader dr = ConnDB.ExecuteReader(sql); string temp = ""; while (dr.Read()) { temp += "" + dr[1].ToString() + "
"; } return temp; } public string LoadTemplate(string tempname) { return File.ReadAllText(MapPath(tempname),gb); } public void SavePage(string filename, string data) { byte[] buffer = gb.GetBytes(data); FileStream fs = File.OpenWrite(MapPath(filename)); fs.Write(buffer, 0, buffer.Length); fs.Flush(); fs.Close(); } protected void Button2_Click(object sender, EventArgs e) { string sql = "select * from Products"; SqlDataReader dr = ConnDB.ExecuteReader(sql); while (dr.Read()) { string temp = LoadTemplate("NewsDetail.txt"); temp = temp.Replace("[--@title--]", dr["ProductName"].ToString()); temp = temp.Replace("[--@categoryname--]", dr["CategoryID"].ToString()); temp = temp.Replace("[--@author--]", dr["SupplierID"].ToString()); temp = temp.Replace("[--@postdate--]", DateTime.Now.ToLongDateString()); temp = temp.Replace("[--@content--]", dr["quantityperunit"].ToString()); string fn="news"+dr["ProductID"].ToString()+".html"; SavePage(fn,temp); } } protected void Button4_Click(object sender, EventArgs e) { int PageSize = 20; object obj = ConnDB.ExecuteScalar("exec paging 0,0,1"); double PageCount= Convert.ToInt32(Math.Ceiling(Convert.ToDouble(obj) / PageSize)); for (int i = 1; i <= PageCount; i++) { string temp = LoadTemplate("NewsList.txt"); string str = ""; string sql = "exec paging " + (i-1) * PageSize + "," +i* PageSize + ",0"; SqlDataReader dr = ConnDB.ExecuteReader(sql); string str1 = ""; while (dr.Read()) { str1 += "" + dr[1].ToString() + "
"; } #region 生成页码 for (int j = 1; j <= PageCount; j++) { if (i == j) { str+= j; } else { str += ""+j+""; } } #endregion temp = temp.Replace("[--@newslist--]", str1); temp =temp.Replace("[--@pager--]", str); SavePage("NewsList" + i + ".html", temp); } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 动态生成静态
 输入关键字,在本站1000多万海量源码库中尽情搜索: