/// <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/" οnclick=/"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); }