生成静态分页模板
2009-09-02 22:01
218 查看
/// <summary>
/// 分页设置
/// </summary>
/// <param name="strListName">列表名称</param>
/// <param name="strFileName">文件名</param>
/// <param name="pSize">列表行数</param>
/// <param name="pIndex">当前页码</param>
/// <param name="pCount">总记录数</param>
private void setPager(string strListName, string strFileName, int pSize, int pIndex, int pCount)
{
string[] strPages = new string[4];
string strTpl = ListTpl[3];
bool ShowPageIndex = strTpl.IndexOf("{$ShowPageIndex}") != -1;
bool ShowGoToPage = strTpl.IndexOf("{$ShowGoToPage}") != -1;
int allpage = 0;
strPages[0] = strFileName + "_1.html";
strPages[1] = strFileName + "_" + (pIndex - 1) + ".html";
strPages[2] = strFileName + "_" + ((pIndex + 1) > pCount ? pCount : (pIndex + 1)) + ".html";
strPages[3] = strFileName + "_" + pCount + ".html";
string strNoLink = "javascript:void(0);/" class=/"nolink/"";
if (ShowPageIndex)
{
string strTxt = "";
if (pIndex < 1) { pIndex = 1; }
if (pSize != 0)
{
pSize = 1;
allpage = (pCount / pSize);
allpage = ((pCount % pSize) != 0 ? allpage + 1 : allpage);
allpage = (allpage == 0 ? 1 : allpage);
}
int startcount = 0;
int endcount = 0;
startcount = (pIndex + 5) > allpage ? allpage - 9 : pIndex - 4;//中间页起始序号
endcount = pIndex < 5 ? 9 : pIndex + 4;//中间页终止序号
if (startcount < 1) { startcount = 1; }
if (allpage < endcount) { endcount = allpage; }
for (int i = startcount; i <= endcount; i++)
{
if (i != pIndex)
strTxt += string.Format(" <a href="/" mce_href="/""{0}/">{1}</a> ", strFileName + "_" + i + ".html", i);
else
strTxt += " <a class=/"nolink/">" + i + "</a> ";
}
strTpl = strTpl.Replace("{$ShowPageIndex}", strTxt);
}
if (ShowGoToPage)
{
string strTxt = "<input id=/"pIndex/" size=/"4/" value=/"{0}/" /> <input type=/"button/" value=/"GO/" onclick=/"javascript:var idx = document.getElementById('pIndex').value;if(idx>0 && idx<={1})window.location='{2}'+idx+'.html';/" />";
strTpl = strTpl.Replace("{$ShowGoToPage}", string.Format(strTxt, pIndex, pCount, strFileName + "_"));
}
if (pIndex == 1)
{
strPages[0] = strNoLink;
strPages[1] = strNoLink;
}
else if (pIndex == pCount)
{
strPages[2] = strNoLink;
strPages[3] = strNoLink;
}
this["#List:" + strListName] += string.Format(strTpl, strPages);
}
/// 分页设置
/// </summary>
/// <param name="strListName">列表名称</param>
/// <param name="strFileName">文件名</param>
/// <param name="pSize">列表行数</param>
/// <param name="pIndex">当前页码</param>
/// <param name="pCount">总记录数</param>
private void setPager(string strListName, string strFileName, int pSize, int pIndex, int pCount)
{
string[] strPages = new string[4];
string strTpl = ListTpl[3];
bool ShowPageIndex = strTpl.IndexOf("{$ShowPageIndex}") != -1;
bool ShowGoToPage = strTpl.IndexOf("{$ShowGoToPage}") != -1;
int allpage = 0;
strPages[0] = strFileName + "_1.html";
strPages[1] = strFileName + "_" + (pIndex - 1) + ".html";
strPages[2] = strFileName + "_" + ((pIndex + 1) > pCount ? pCount : (pIndex + 1)) + ".html";
strPages[3] = strFileName + "_" + pCount + ".html";
string strNoLink = "javascript:void(0);/" class=/"nolink/"";
if (ShowPageIndex)
{
string strTxt = "";
if (pIndex < 1) { pIndex = 1; }
if (pSize != 0)
{
pSize = 1;
allpage = (pCount / pSize);
allpage = ((pCount % pSize) != 0 ? allpage + 1 : allpage);
allpage = (allpage == 0 ? 1 : allpage);
}
int startcount = 0;
int endcount = 0;
startcount = (pIndex + 5) > allpage ? allpage - 9 : pIndex - 4;//中间页起始序号
endcount = pIndex < 5 ? 9 : pIndex + 4;//中间页终止序号
if (startcount < 1) { startcount = 1; }
if (allpage < endcount) { endcount = allpage; }
for (int i = startcount; i <= endcount; i++)
{
if (i != pIndex)
strTxt += string.Format(" <a href="/" mce_href="/""{0}/">{1}</a> ", strFileName + "_" + i + ".html", i);
else
strTxt += " <a class=/"nolink/">" + i + "</a> ";
}
strTpl = strTpl.Replace("{$ShowPageIndex}", strTxt);
}
if (ShowGoToPage)
{
string strTxt = "<input id=/"pIndex/" size=/"4/" value=/"{0}/" /> <input type=/"button/" value=/"GO/" onclick=/"javascript:var idx = document.getElementById('pIndex').value;if(idx>0 && idx<={1})window.location='{2}'+idx+'.html';/" />";
strTpl = strTpl.Replace("{$ShowGoToPage}", string.Format(strTxt, pIndex, pCount, strFileName + "_"));
}
if (pIndex == 1)
{
strPages[0] = strNoLink;
strPages[1] = strNoLink;
}
else if (pIndex == pCount)
{
strPages[2] = strNoLink;
strPages[3] = strNoLink;
}
this["#List:" + strListName] += string.Format(strTpl, strPages);
}
相关文章推荐
- 利用PHP与Smarty模板技术生成分页静态页面的代码
- 利用PHP与Smarty模板技术生成分页静态页面的代码
- 用模板页面 生成静态页面 实现文章分页
- 利用模板将指定目录下的所有图片自动生成含多个分页的图片静态网页
- C#(asp.net)根据静态模板生成静态(html)页面
- asp.net 通过模板生成静态html
- 通过模板生成静态html页面示例
- 【原创】asp.net2.0动态生成静页,静态分页实例介绍
- 基于T4模板引擎生成静态网站(CMS)
- 不用模板,只用ASP+FSO生成静态HTML页的一个方法
- 谈PHP生成静态页面分析 模板+缓存+写文件
- 一个生成静态网页的分页导航条函数
- 生成html静态文件后的分页(客户端版)
- ASP2HTML WITH TEMPLET (ASP运用模板技术生成HTML静态实例)
- 使用ASP.NET模板生成HTML静态页面的五种方案
- 生成静态分页 html 页面
- 使用Spring计时器和velocity模板定时生成静态html/jsp文件
- 几种静态页面生成的代码,包括带内容分页的生成静态
- (转)基于T4模板引擎生成静态网站(CMS)
- php文章内容分页并生成相应的htm静态页面代码