首页 新闻 会员 周边 捐助

有没有园友自己开发的jquery分页控件

0
[已关闭问题] 关闭于 2011-12-07 15:07

rt,谢谢。

lorgine的主页 lorgine | 菜鸟二级 | 园豆:245
提问于:2011-05-20 21:23
< >
分享
所有回答(1)
0

js分页不利于 seo

试试 我写的这个吧

/// <summary>
/// 生成HTML分页链接(By Yipeng)
/// </summary>
/// #pager{color:#2E6AB1;font-size:12px;line-height:200%;text-align:center;margin:25px 0}#pager a{border:1px solid #9AAFE5;color:#2E6AB1;margin-right:4px;text-decoration:none;padding:2px 5px}#pager span.current{background-color:#2E6AB1;border:1px solid navy;color:#FFF;font-weight:700;margin-right:4px;padding:2px 5px}
/// <param name="RecordsTotal">总记录数</param>
/// <param name="pageSize">每页显示记录数</param>
/// <param name="currentPage">当前页码</param>
/// <param name="pageNumSize">一次性显示的页码数量</param>
/// <param name="linkFormat">链接格式 如:"Index.aspx?page={0}、Index/page/{0}"</param>
/// <param name="maxPageSize"> 最多显示的页数(为了性能需要)</param>
/// <returns></returns>
public static string PrintPagerLinks(int RecordsTotal, int pageSize, int currentPage, int pageNumSize, string linkFormat, int? maxPageSize)
{
// "<div id=\"pager\"><a onclick=\"\" href=\"/page8\">&lt; Prev</a><a onclick=\"\" href=\"/page1\">1</a>··· <a onclick=\"\" href=\"/page4\">4</a><a onclick=\"\" href=\"/page5\">5</a><a onclick=\"\" href=\"/page6\">6</a><a onclick=\"\" href=\"/page7\">7</a><a onclick=\"\" href=\"/page8\">8</a><span class=\"current\">9</span><a onclick=\"\" href=\"/page10\">10</a><a onclick=\"\" href=\"/page11\">11</a><a onclick=\"\" href=\"/page12\">12</a><a onclick=\"\" href=\"/page13\">13</a><a onclick=\"\" href=\"/page14\">14</a>··· <a onclick=\"\" href=\"/page200\">200</a><a onclick=\"\" href=\"/page10\">Next &gt;</a></div>";
StringBuilder html = new StringBuilder();
int totalPageNum = (int)Math.Ceiling((double)RecordsTotal / (double)pageSize);
if (maxPageSize.HasValue && totalPageNum > maxPageSize)
totalPageNum
= maxPageSize.Value;
if (totalPageNum == 1)
{
return string.Empty;
}
html.Append(
"<div id=\"pager\">");
if (currentPage > 1)
{
html.AppendFormat(
"<a href=\"{0}\">上一页</a>", string.Format(linkFormat, currentPage - 1));
}

int startNum = 1;
int endNum = totalPageNum;
if (pageNumSize < totalPageNum)
{
startNum
= currentPage - (pageNumSize / 2);
startNum
= startNum < 1 ? 1 : (startNum + pageNumSize > totalPageNum ? totalPageNum - pageNumSize : startNum);
endNum
= startNum + pageNumSize;
}
if (startNum > 1)
{
html.AppendFormat(
"<a href=\"{0}\">{1}</a>&hellip;", string.Format(linkFormat, 1), 1);
}
for (int i = startNum; i <= endNum; i++)
{
if (currentPage == i)
{
html.AppendFormat(
"<span class=\"current\">{0}</span>", i);
}
else
{
html.AppendFormat(
"<a href=\"{0}\">{1}</a>", string.Format(linkFormat, i), i);

}
}
if (endNum < totalPageNum)
{
html.AppendFormat(
"&hellip;&hellip; <a href=\"{0}\">{1}</a>", string.Format(linkFormat, totalPageNum), totalPageNum);
}
if (currentPage < totalPageNum)
{
html.AppendFormat(
"<a href=\"{0}\">下一页</a>", string.Format(linkFormat, currentPage + 1));
}
html.Append(
"</div>");

return html.ToString();
}

慧☆星 | 园豆:5722 (大侠五级) | 2011-05-21 09:45
服务器端的,我也写了一个。不过还是谢谢。
支持(0) 反对(0) lorgine | 园豆:245 (菜鸟二级) | 2011-05-21 13:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册