100分 求生成静态html如何分页

ttg520 2007-05-16 10:38:23
经过几天学习现在文章已经生成html了 但是怎么分页呢?
...全文
481 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
iuhxq 2007-06-28
  • 打赏
  • 举报
回复
其他人也很认真的帮助你,虽然结果没有被采纳,但你一样要谢谢人家
ttgitfk520 2007-06-28
  • 打赏
  • 举报
回复
这是我以前写的
public static string getHotsNews(string typeID,int pageCount,int pageSize)
{
StringBuilder strBuilder= new StringBuilder();
DataTable dt = new DataTable();
dt = InfoDAO.getAllInfoListByType(typeID).Tables[0];
int countPage = dt.Rows.Count;
//int nPage = 3;//每页显示30行
strBuilder.Append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
int nPage = 0;
if (pageSize * pageCount >= countPage)
{
nPage = countPage;
}
else
{
nPage = pageSize * pageCount;
}
for (int i = (pageCount - 1) * pageSize; i < nPage; i++)
{
strBuilder.Append("<tr><td height=\"20\"> <img src=\"../../images/jian.jpg\" /> <a href=" + dt.Rows[i]["htmlFile"].ToString() + " class=\"text1\" target=\"_blank\">" + dt.Rows[i]["topic"].ToString() + " " + ((DateTime)dt.Rows[i]["createDate"]).ToString("yyyy-MM-dd") + "</a></td></tr>");
}
strBuilder.Append("<tr><td align=\"center\" height=\"25\">");
strBuilder.Append("页次:<span class=\"redfont\">" + pageCount + "</span>/" + (countPage / pageSize + 1) + " " + pageSize + "篇/页 ");
if (pageCount == 1)
{
strBuilder.Append("<span class=\"text7\">首页</span>");
strBuilder.Append("<span class=\"text7\"> 上一页</span>");
}
else
{
strBuilder.Append("<a href=category" + "_" + typeID + "_" + 1 + ".html class=\"text1\">" + "首页" + "</a>");
strBuilder.Append(" ");
strBuilder.Append("<a href=category" + "_" + typeID + "_" + (pageCount - 1) + ".html class=\"text1\">" + "上一页" + "</a>");
}
strBuilder.Append(" ");
if (pageCount <= countPage / pageSize)
{
strBuilder.Append("<a href=category" + "_" + typeID + "_" + (pageCount + 1) + ".html class=\"text1\">" + "下一页" + "</a>");
strBuilder.Append(" " + "<a href=category" + "_" + typeID + "_" + (countPage / pageSize + 1) + ".html class=\"text1\">" + "尾页" + "</a>");
}
else
{
strBuilder.Append("<span class=\"text7\">下一页</span></a>");
strBuilder.Append("<span class=\"text7\"> 尾页</span></a>");
}
strBuilder.Append(" 共<span class=\"redfont\">" + countPage + "</span>篇");
strBuilder.Append(" Go:<select name=\"select\" onChange='javascript:window.open(this.options[this.selectedIndex].value,\"_self\")'>");
for (int i = 1; i <= (countPage / pageSize + 1); i++)
{
if (i == pageCount)
{
strBuilder.Append("<option value=category" + "_" + typeID + "_" + i + ".html selected>第" + i + "页</option>");
}
else
{
strBuilder.Append("<option value=category" + "_" + typeID + "_" + i + ".html>第" + i + "页</option>");
}
}
strBuilder.Append("</select>");
strBuilder.Append("</table>");
return strBuilder.ToString();
}
shun1984a 2007-06-04
  • 打赏
  • 举报
回复
http://www.51aspx.com/CV/AspNetToHtm/
  • 打赏
  • 举报
回复
mark ,学习
budong0000 2007-06-04
  • 打赏
  • 举报
回复
mark
LoveMango 2007-06-04
  • 打赏
  • 举报
回复
mark
zdyguilong 2007-06-04
  • 打赏
  • 举报
回复
你说的是把新闻内容分页么?
如果是的话看看这个
http://blog.csdn.net/zdyguilong/archive/2007/05/24/1624491.aspx

这个是我星期五发的帖子
http://community.csdn.net/Expert/topic/5574/5574174.xml?temp=8.932132E-02
ttg520 2007-05-16
  • 打赏
  • 举报
回复
还没有搞定 继续求助
ttg520 2007-05-16
  • 打赏
  • 举报
回复
murfya
我申请了
murfya 2007-05-16
  • 打赏
  • 举报
回复
加入ASP。NET C#群吧,群号是: 1873156
mdl821120 2007-05-16
  • 打赏
  • 举报
回复
好像单有分页的控件,我见过,但没记下来,楼主找找
Xpengfee 2007-05-16
  • 打赏
  • 举报
回复
大虾们可不可以写的详细些,俺们也跟着学习学习
ttg520 2007-05-16
  • 打赏
  • 举报
回复
iloveaspx(记得给分)
有没有代码
fchs520 2007-05-16
  • 打赏
  • 举报
回复
加分页标记(如 $PAGE$) 然后自动按照 aaa_1.htm aaa_2.htm进行分
LS正解啊
NqIceCoffee 2007-05-16
  • 打赏
  • 举报
回复
1.写好aspx页,抓取当前页下的aspx的数据===>存为HTML

2.写好模板,获取当前页要替换的数据,替换掉模板中的替换符,得到当前页的数据===>存为HTML


iloveaspx 2007-05-16
  • 打赏
  • 举报
回复
加分页标记(如 $PAGE$) 然后自动按照 aaa_1.htm aaa_2.htm进行分
ttg520 2007-05-16
  • 打赏
  • 举报
回复
比如我怎样前20篇归到html_1.html 20-40归到html_2.html 但是在程序里怎么写呢
lilopeng 2007-05-16
  • 打赏
  • 举报
回复
一个页号对应一个html文件不就得了!
Aricc 2007-05-16
  • 打赏
  • 举报
回复
今天刚弄完这个。
不过,我用的是ASP。
但是,思想是可以重用的。
设定好PageSize,读取记录,获得记录总数TotalNumber。
通过这两个参数计算得到页面数PageNum。
然后倒序读取记录,每PageSize条记录生成一页。
至于分页,你可以看一下新云的那个。用的JS的。
ConnectionString 2007-05-16
  • 打赏
  • 举报
回复
先循环得到页码,然后:
public static bool CreateHtml(string url, string path)
{
try
{
string cutPath = path.Substring(0, path.LastIndexOfAny(new char[] { '/', '\\' }));
if (!System.IO.Directory.Exists(cutPath)) System.IO.Directory.CreateDirectory(cutPath);
System.Net.WebRequest request = System.Net.WebRequest.Create(url);
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream stream = response.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(stream, System.Text.Encoding.Default);
FileInfo file = new FileInfo(path);
FileStream fs = file.OpenWrite();
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
sw.WriteLine(sr.ReadToEnd());
sw.Flush();
sw.Close();
stream.Close();
sr.Close();
return true;
}
catch
{
return false;
}
}
加载更多回复(2)

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧