您的位置:首页 > 其它

长文章中插入分页符^进行分页

2010-03-06 16:45 211 查看
我知道怎么做了,供大家参考:

在长文章中插入分页符^进行分页

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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: