/// <summary>/// 获得伪静态页码显示链接/// </summary>/// <param name="curPage">当前页数</param>/// <param name="countPage">总页数</param>/// <param name="url">超级链接地址</param>/// <param name="extendPage">周边页码显示个数上限</param>/// <param name="forumrewrite">当前版块是否使用URL重写</param>/// <returns>页码html</returns>public static string GetStaticPageNumbers(int curPage, int countPage, string url, string expname, int extendPage, int forumrewrite){int startPage = 1;int endPage = 1;string t1 = "<font><a href=\"" + url + "-" + (curPage - 1) + expname + "\">< 上一页</a></font>";string t2 = "<font><a href=\"" + url + "-" + (curPage + 1) + expname + "\">下一页 ></a></font>";string more = "<font>…</font>";if (countPage < 1) countPage = 1;if (extendPage < 3) extendPage = 2;if (countPage > extendPage){if (curPage - (extendPage / 2) > 0){if (curPage + (extendPage / 2) < countPage){startPage = curPage - (extendPage / 2);endPage = startPage + extendPage - 1;}else{endPage = countPage;startPage = endPage - extendPage + 1;if (curPage == endPage)t2 = " <font class=\"h_bkd\">下一页 ></font>";}}else{endPage = extendPage;if (curPage == 1)t1 = " <font class=\"h_bkd\">< 上一页</font>";}}else{startPage = 1;endPage = countPage;if (curPage == 1)t1 = " <font class=\"h_bkd\">< 上一页</font>";if (curPage == endPage)t2 = " <font class=\"h_bkd\">下一页 ></font>";}StringBuilder s = new StringBuilder("");s.Append(t1);if (startPage > 1){s.Append("<font><a href=\"" + url + "-1" + expname + "\">1</a></font>" + more);}for (int i = startPage; i <= endPage; i++){if (i == curPage){s.Append("<font class=\"fenye_qd\">" + i + "</font>");}else{s.Append("<font><a href=\"");s.Append(url);if (i != 1){s.Append("-");s.Append(i);}s.Append(expname);s.Append("\">");s.Append(i);s.Append("</a></font>");}}if (endPage < countPage)s.Append(more + "<font><a href=\"" + url + "-" + countPage + expname + "\">" + countPage + "</a></font>");s.Append(t2);s.Append("<font class=\"fy_top\"><a href=\"#\"><img src=\"/images/top_03.gif\" width=\"57\" border=\"0\" height=\"20\" alt=\"返回头部\" /></a></font>");return s.ToString();}/// <summary>/// 获得动态页码显示链接/// </summary>/// <param name="curPage">当前页数</param>/// <param name="countPage">总页数</param>/// <param name="url">超级链接地址</param>/// <param name="extendPage">周边页码显示个数上限</param>/// <param name="pagetag">页码标记</param>/// <param name="anchor">锚点</param>/// <returns>页码html</returns>public static string GetPageNumbers(int curPage, int countPage, string url, int extendPage, int totals, int pageSize){string pagetag = "curpage";int startPage = 1;int endPage = 1;if (url.IndexOf("?") > 0){url = url + "&";}else{url = url + "?";}//string t3 = "<font><a href=\"" + url + pagetag + "=1&pagesize="+pageSize+" \">首页</a></font>";//string t4 = "<font><a href=\"" + url + pagetag + "=" + countPage + "&pagesize=" + pageSize + " \">尾页</a></font>";string t1 = "<font><a href=\"" + url + pagetag + "=" + (curPage - 1) + "&pagesize=" + pageSize + "\">< 上一页</a></font>";string t2 = "<font><a href=\"" + url + pagetag + "=" + (curPage + 1) + "&pagesize=" + pageSize + "\">下一页 ></a></font>";string more = "<font>...</font>";if (countPage < 1) countPage = 1;if (extendPage < 3) extendPage = 2;if (countPage > extendPage){if (curPage - (extendPage / 2) > 0){if (curPage + (extendPage / 2) < countPage){startPage = curPage - (extendPage / 2);endPage = startPage + extendPage - 1;}else{endPage = countPage;startPage = endPage - extendPage + 1;if (curPage == endPage){t2 = "<font class=\"h_bkd\">下一页 ></font>";//t4 = "<font class=\"h_bkd\">尾页</font>";}}}else{endPage = extendPage;if (curPage == 1){t1 = "<font class=\"h_bkd\">< 上一页</font>";// t3 = "<font class=\"h_bkd\">首页</font>";}}}else{startPage = 1;endPage = countPage;if (curPage == 1){t1 = "<font class=\"h_bkd\">< 上一页</font>";// t3 = "<font class=\"h_bkd\">首页</font>";}if (curPage == endPage){t2 = "<font class=\"h_bkd\">下一页 ></font>";//t4 = "<font class=\"h_bkd\">尾页</font>";}}StringBuilder s = new StringBuilder("");//s.Append("共" + totals + "条记录 ");//s.Append(t3);s.Append(t1);if (startPage > 1){s.Append("<font><a href=\"" + url + pagetag + "=1&pagesize=" + pageSize + "\"> 1 " + more + " </a></font>");}for (int i = startPage; i <= endPage; i++){if (i == curPage){s.Append("<font class=\"fenye_qd\">" + i + "</font>");}else{s.Append("<font><a href=\"");s.Append(url);s.Append(pagetag);s.Append("=");s.Append(i);s.Append("&pagesize=" + pageSize + "\">");s.Append(i);s.Append("</a><font>");}}if (endPage < countPage)s.Append("<font><a href=\"" + url + pagetag + "=" + countPage + "&pagesize=" + pageSize + "\">"+ more + countPage + "</a></font>");s.Append(t2);//s.Append(t4);s.Append(ReturnPageString(countPage, curPage));s.Append(" <input type=\"text\" size=\"2\" value=\"" + pageSize + "\" οnchange=\"Utils.SetPageSize(this);\" />条/页");return s.ToString();}/// <summary>/// 输出回转页面/// </summary>/// <param name="countPage">总页数</param>/// <param name="curPage">当前页码</param>/// <returns></returns>private static string ReturnPageString(int countPage, int curPage){string html = " <font>到第{0}页</font>";string str = "<select name=\"turnpage\" id=\"turnpage\" class=\"fengyi select\" οnchange=\"Utils.TurnPage(this);\">";for (int i = 1; i <= countPage; i++){if (i == curPage)str += string.Format("<option value=\"{0}\" selected=\"selected\" >{0}</option>", i);elsestr += string.Format("<option value=\"{0}\">{0}</option>", i);}str += "</select>";return string.Format(html, str);}/// <summary>/// 取得动态地址/// </summary>/// <param name="indexPage">当前页码</param>/// <param name="pageCount">总页数</param>/// <param name="url">页面地址</param>/// <returns></returns>public static string GetPageHeadString(int indexPage, int pageCount, string url){StringBuilder builder = new StringBuilder();if (url.LastIndexOf("?") == -1)url = url + "?";elseurl = url + "&";builder.Append("<font class=\"fy_shuzi\">" + indexPage + "/" + pageCount + "</font>");if (indexPage == 1)builder.Append("<img height=\"17\" border=\"0\" width=\"16\" src=\"/images/sp_botton_03.gif\" alt=\"上一页\" class=\"middle\"> ");elsebuilder.Append("<a href=\"" + url + "curpage=" + (indexPage - 1).ToString() + "\"><img height=\"17\" border=\"0\" width=\"16\" src=\"/images/sp_botton_032.gif\" alt=\"上一页\" class=\"middle\"></a> ");if (pageCount != indexPage){builder.Append(" <a href=\"" + url + "curpage=" + (indexPage + 1).ToString() + "\"><img height=\"17\" border=\"0\" width=\"51\" src=\"/images/sp_botton_05.gif\" alt=\"下一页\" class=\"middle\"></a>");}else{builder.Append(" <img height=\"17\" border=\"0\" width=\"51\" src=\"/images/xiahui.gif\" alt=\"下一页\" class=\"middle\">");}return builder.ToString();}