asp.net使用FCK編輯器中的分頁(yè)符實(shí)現(xiàn)長(zhǎng)文章分頁(yè)功能
本文實(shí)例講述了asp.net使用FCK編輯器中的分頁(yè)符實(shí)現(xiàn)長(zhǎng)文章分頁(yè)功能。分享給大家供大家參考,具體如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SplitContent.aspx.cs" Inherits="SplitContent" %> <%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> <asp:Panel ID="pnlPage" runat="server" Height="286px"> <asp:Label ID="ltlContent" runat="server" Text="ltlContent"></asp:Label> <br /> <asp:Label ID="ltlPage" runat="server" Text="ltlPage"></asp:Label> </asp:Panel> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class SplitContent : System.Web.UI.Page { private static string a = "123456"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //文章分頁(yè)頁(yè)碼 int currentPage = Request["cpage"] == null ? 1 : Convert.ToInt32(Request["cpage"]); //URL地址 string pageUrl = Request.Url.ToString(); ArticlePage(a, currentPage, pageUrl); } } /// <summary> ///文章分頁(yè)函數(shù) /// </summary> /// <param name="content">文章內(nèi)容</param> /// <param name="currentPage">當(dāng)前頁(yè)碼</param> /// <param name="pageUrl">當(dāng)前頁(yè)面地址</param> protected void ArticlePage(string content, int currentPage, string pageUrl) { pageUrl = !pageUrl.Contains("?") ? pageUrl + "?" : pageUrl.Replace("&cpage=" + currentPage, ""); int pageCount = 0;//頁(yè)數(shù) content = content.Replace("<div style=\"page-break-after: always\"><span style=\"display: none\"> </span></div>", "[--page--]");//FCK在IE中生成的默認(rèn)分頁(yè)符,替換為自定義分頁(yè)符 content = content.Replace("<div style=\"page-break-after: always\"><span style=\"display: none\"> </span></div>", "[--page--]");//FCK在FF中生成的默認(rèn)分頁(yè)符,替換為自定義分頁(yè)符 string[] tempContent = System.Text.RegularExpressions.Regex.Split(content, "\\[--page--]"); //取得分頁(yè)符 "\\["為"["的轉(zhuǎn)義 pageCount = tempContent.Length; string outputContent = "";//要輸出的內(nèi)容 if (pageCount <= 1) { outputContent = content; //文章內(nèi)容 this.pnlPage.Visible = false; } else { string pageStr = "";//分頁(yè)字符串 pageStr += "共<span class='count'>" + pageCount + "</span>頁(yè) "; if (currentPage != 1) { pageStr += " <a class='prev' href =" + pageUrl + "&cpage=" + (currentPage - 1) + ">上頁(yè)</a>"; } for (int i = 1; i <= pageCount; i++) { if (i == currentPage) pageStr += (" <span class='active'>" + i + "</span>"); else pageStr += (" <a class='num' href =" + pageUrl + "&cpage=" + i + ">" + i + "</a>"); } if (currentPage != pageCount) { pageStr += " <a class='next' href =" + pageUrl + "&cpage=" + (currentPage + 1) + ">下頁(yè)</a>"; } this.ltlPage.Text = pageStr; outputContent = tempContent[currentPage - 1].ToString(); } this.ltlContent.Text = outputContent; } }
更多關(guān)于asp.net相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《asp.net操作json技巧總結(jié)》、《asp.net字符串操作技巧匯總》、《asp.net操作XML技巧總結(jié)》、《asp.net文件操作技巧匯總》、《asp.net ajax技巧總結(jié)專題》及《asp.net緩存操作技巧總結(jié)》。
希望本文所述對(duì)大家asp.net程序設(shè)計(jì)有所幫助。
- ASp.net下fckeditor配置圖片上傳最簡(jiǎn)單的方法
- asp.net FCKeditor自定義非空驗(yàn)證
- ASP.NET中FCKEDITOR在線編輯器的用法
- Asp.net FCKEditor 2.6.3 上傳文件沒(méi)有權(quán)限解決方法
- asp.net 為FCKeditor開(kāi)發(fā)代碼高亮插件實(shí)現(xiàn)代碼
- ASP.NET 高性能分頁(yè)代碼
- Asp.Net中的三種分頁(yè)方式總結(jié)
- asp.net Datalist控件實(shí)現(xiàn)分頁(yè)功能
- asp.net 文章內(nèi)容分頁(yè)顯示的代碼
- asp.net repeater手寫分頁(yè)實(shí)例代碼
- asp.net下Repeater使用 AspNetPager分頁(yè)控件
- asp.net中g(shù)ridview的查詢、分頁(yè)、編輯更新、刪除的實(shí)例代碼
相關(guān)文章
Asp.net+jquery+.ashx文件實(shí)現(xiàn)分頁(yè)思路
分頁(yè)思路: .ashx程序中,編寫好取得不同頁(yè)碼的程序。在頁(yè)面布局好的前提下,留下數(shù)據(jù)區(qū)域 div。然后在頁(yè)面請(qǐng)求 .ashx程序生成下一頁(yè)的html代碼。覆蓋div.innerHTMl2013-03-03Visual Studio 2017正式版發(fā)布 亮點(diǎn)看這里
終于等到你,最強(qiáng) IDE Visual Studio 2017 正式版發(fā)布,這篇文章主要為大家詳細(xì)解析了Visual Studio 2017正式版發(fā)布的細(xì)節(jié),亮點(diǎn)看這里2017-03-03ASP.NET中 Execl導(dǎo)出的六種方法實(shí)例
這篇文章主要介紹了ASP.NET中 Execl導(dǎo)出的六種方法實(shí)例,有需要的朋友可以參考一下2013-12-12支持ASP.NET MVC、WebFroM的表單驗(yàn)證框架ValidationSuar使用介紹
這篇文章主要介紹了支持ASP.NET MVC、WebFroM的表單驗(yàn)證框架ValidationSuar使用介紹,本文詳細(xì)講解了使用步驟,并給出一個(gè)完整Demo下載,需要的朋友可以參考下2015-06-06jQuery AJax調(diào)用asp.net webservers的實(shí)現(xiàn)代碼
代碼是轉(zhuǎn)載來(lái)的 本來(lái)今天寫的 但是到現(xiàn)在還沒(méi)搞懂,慚愧啊2009-12-12Asp.Net平臺(tái)下的圖片在線裁剪功能的實(shí)現(xiàn)代碼(源碼打包)
最近項(xiàng)目中有個(gè)圖片在線裁剪功能,本人查找資料,方法如下:前臺(tái)展現(xiàn)用jquery.Jcrop實(shí)現(xiàn),后臺(tái)使用 System.Drawing.Image類來(lái)進(jìn)行裁剪2011-10-10document.getElementsByName和document.getElementById 在IE與FF中不同
今天在<asp:radiobuttonlist/>中使用教本的的時(shí)候才注意到原來(lái) document.getElementsByName 、document.getElementById 在IE與FF中有著不同實(shí)現(xiàn)。2008-12-12