需要在目标位置加入分页标记。具体的代码为:
public string bind(string content, string Id)
{
string[] temp = content.Trim().Split('㊣');
string html = "<table><tr>";
int page;
if (System.Web.HttpContext.Current.Request.QueryString["page"] == null)
{
html += "<td>" + temp[0] + "</td></tr></table>";
}
else
{
char[] isid = System.Web.HttpContext.Current.Request.QueryString["id"].ToCharArray();
foreach (char c in isid)
{
if (!char.IsDigit(c))
{
System.Web.HttpContext.Current.Response.Write("<script language=javascript>alert('参数错误!');window.close();</script>");
System.Web.HttpContext.Current.Response.End();
page = 0;
}
}
page = int.Parse(System.Web.HttpContext.Current.Request.QueryString["page"]);
if (int.Parse(System.Web.HttpContext.Current.Request.QueryString["page"]) > temp.Length)
{
System.Web.HttpContext.Current.Response.Write("<script>alert('输入参数超过最大页数!');history.back();</script>");
System.Web.HttpContext.Current.Response.End();
page = 0;
}
html += "<td>" + temp[page - 1] + "</td></tr></table>";
}
string thispage = "";
if (temp.Length > 1)
{
thispage = "<table align=center><tr><td>[<a href=?id=" + Id + "&page=1>首页</a>]</td>";
for (int i = 0; i <= temp.Length - 1; i++)
{
thispage += "<td>[<a href=?id=" + Id + "&page=" + (i + 1) + ">" + (i + 1) + "</a>]</td>";
}
thispage += "<td><a href=?id=" + Id + "&page=" + (temp.Length) + ">[尾页]</td></tr></table>";
}
return html + thispage;
}
引用: info = content.bind(info, Request.QueryString["id"]);