C#改进的分页显示

public static string pagelist(int intpage, int pagecount) { String urlpath; String TemplatePage; int page2; urlpath = urls(); TemplatePage = "

/n"; TemplatePage +=(intpage == 1)? "首 页 前一页": "首 页 /n 前一页"; page2 = (intpage - (intpage % 5)) / 5; if (page2 < 1) page2 = 0; for (int s = page2 * 5 - 1; s <= page2 * 5 + 5; s++) { if (s > 0) { TemplatePage += (s == intpage) ? "" + s.ToString() + "" : "" + s.ToString() + ""; if (s == pagecount) break; } } TemplatePage += (intpage == pagecount)? "后一页 尾 页": "后一页 /n 尾 页"; TemplatePage += "
"; return TemplatePage; } public static string urls() { String currurl = HttpContext.Current.Request.RawUrl; String querystring = null; String querts1=""; int iqs = currurl.IndexOf('?'); if (iqs == -1) { querts1 = currurl + "?"; return "/" + querts1; } else if (iqs >= 0) { querts1 = currurl.Substring(1, iqs); querystring = (iqs < currurl.Length - 1) ? currurl.Substring(iqs + 1) : String.Empty; NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring); StringBuilder sb = new StringBuilder(); foreach (String s in qscoll.AllKeys) { if (s.ToLower() != "page") sb.Append(s + "=" + qscoll[s] + "&"); } return "/" + querts1 + sb.ToString(); } else return ""; }

你可能感兴趣的:(C#入门学习,c#,string,class,null,div)