Asp.Net实现长文章分页显示功能

//写一个类
public class SplictPage
{
    public static string bind(string content, string Id)
    {
        string thisnr = "";
        string thispage = "";
        string[] temp = content.Trim().Split(<a href="mailto:'{@cpbcw}');">'{$cpbcw$}');</a>        if (System.Web.HttpContext.Current.Request.QueryString["page"] == null)
        {
         thisnr = "<div>" + temp[0] + "</div>";
        }
        else
        {
            thisnr = "<div>" + temp[System.Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["page"]) - 1] + "</div>";
        }
        if (temp.Length > 1)
        {
            for (int i = 0; i <= temp.Length - 1; i++)
            {
                thispage += "<a href=?x_id=" + Id + "&page=" + (i + 1) + ">[" + (i + 1) + "]</a> ";
            }
        }
        return thisnr + thispage;
    }
}
----------------------
//调用
this.txtcontent.Text = SplictPage.bind(mydr["x_nr"].ToString(), "3");

posted @ 2012-03-09 08:26  Chaoa  阅读(299)  评论(0编辑  收藏  举报