长遍文章分页C#版

来源:互联网 发布:化学品数据库 编辑:程序博客网 时间:2024/05/01 02:51

1.长遍文章分页一般分为两种方式
A.计算文章内容长度,然后内容长度除以每页固定值,自动给文章分页.原理和B差不多,网上代码很多,就没有贴.

B.在文章中插入分页符,根据分页符,自动给文章分页,代码如下:
protected void GetNews(string strNews, int id)
    {
        string[] temp = strNews.Split('^'); //取的分页符

        if (temp.Length <= 0)
        {
            Label1.Text = strNews; //文章内容
        }
        else
        {

            Response.Write("共" + temp.Length + "页");
            for (int i = 0; i < temp.Length; i++)
            {
                Response.Write("<a href =test.aspx?id=" + i + ">" + i + "</a>");
            }
            Label1.Text = temp[id].ToString();
        }

    }