04 |
/// <param name="content">文章内容</param> |
05 |
/// <param name="currentPage">当前页码</param> |
06 |
/// <param name="pageUrl">当前页面地址</param> |
07 |
protected String[] ArticlePage( string content, int currentPage, string pageUrl) |
09 |
String[] result = new String[2]; |
11 |
content = content.Replace( "<div style=\"page-break-after: always\"><span style=\"display: none\"> </span></div>" , "[--page--]" ); |
12 |
string [] tempContent = System.Text.RegularExpressions.Regex.Split(content, "\\u005B--page--]" ); |
13 |
pageCount = tempContent.Length; |
14 |
string outputContent = "" ; |
17 |
outputContent = content; |
18 |
result[0] = String.Empty; |
25 |
pageStr += "<a class='prev' href =" + pageUrl + "_" + (currentPage - 1) + ".html> </a>" ; |
27 |
for ( int i = 1; i <= pageCount; i++) |
30 |
pageStr += ( "<span class='active'>[" + i + "]</span>" ); |
32 |
pageStr += ( "<a class='num' href =" + pageUrl + "_" + i + ".html>[" + i + "]</a>" ); |
34 |
if (currentPage != pageCount) |
36 |
pageStr += "<a class='next' href =" + pageUrl + "_" + (currentPage + 1) + ".html> </a>" ; |
39 |
outputContent = tempContent[currentPage - 1].ToString(); |
41 |
result[1] = outputContent; |
Controller部分
01 |
public ActionResult Attractions( int id, int ? pageid) |
03 |
Pic_info picinfo = new PicDal().GetPic_infoByID(id); |
04 |
String[] result = ArticlePage(picinfo.Pic_Context, pageid ?? 1, "/Attractions/list_" + id); |
05 |
picinfo.Pic_Context = result[1]; |
06 |
ViewData[ "page_num" ] = result[0]; |
View页面:
01 |
<% Pic_info pic = Model as Pic_info; |
05 |
< h3 ><%= pic.Pic_name%></ h3 > |
09 |
< div class = "page_num" ><%= ViewData["page_num"].ToString()%></ div > |
CSS样式:
19 |
background : url (images/page_up.gif) no-repeat ; |
23 |
background : url (images/page_down.gif) no-repeat ; |
37 |
padding : 2px 2px 0 2px ; |
预览:
|