我知道怎么做了,供大家参考:
在长文章中插入分页符^进行分页
content为显示文章内容的label控件
lbpage为显示分页页码的label控件
-
C# code
-
public NewsInfo one = new NewsInfo();
protected void Page_Load( object sender, EventArgs e)
{
if ( ! IsPostBack)
{
one = NewsManage.GetNewsModelByNewsId( " 38 " ); // 举个例子
int page = Convert.ToInt32(Request.QueryString[ " page " ]);
string neirong = one.NeiRong.ToString();
GetNews(neirong, page);
}
}
protected void GetNews( string strNews, int page)
{
string [] temp = strNews.Split( ' ^ ' ); // 取的分页符
if (temp.Length <= 1 )
{
content.Text = strNews; // 文章内容
}
else
{
lbpage.Text = " 共 " + temp.Length + " 页 " ;
for ( int i = 0 ; i < temp.Length; i ++ )
{
lbpage.Text += ( " [<a href =webform1.aspx?page= " + i + " > " + (i + 1 ) + " </a>] " );
}
content.Text = temp[page].ToString();
}
}