asp.net中使用fckeditor分頁符分頁

來源:互聯網
上載者:User

因為網站的需要,想要使用fckeditor對長的新聞進行分頁,在網上找了找,解決方案不明確而且又很散,於是自己動手改改

首先修改FCKeditor\editor\js\裡面的兩個js檔案,fckeditorcode_gecko.js,fckeditorcode_ie.js

1.找到<span style="DISPLAY:none">&nbsp;</span>修改為:$[page]$

2.去掉e.style.pageBreakAfter = 'always';(沒有去掉的話,分頁的時候內容亂了,我也不知道去掉了對不對)

上面修改的就是fckeditor插入分頁符的內容,這樣好在分頁方法裡面替換

下面貼上分頁的方法

/// <summary>    ///文章分頁函數    /// </summary>    /// <param name="content">文章內容</param>    /// <param name="currentPage">當前頁碼</param>    /// <param name="pageUrl">當前頁面地址</param>    protected void ArticlePage(string content, int currentPage, string pageUrl)    {        int pageCount = 0;//頁數        content = content.Replace("<div>$[page]$/div>", "[--page--]");        string[] tempContent = System.Text.RegularExpressions.Regex.Split(content, "\\u005B--page--]"); //取得分頁符 "\\u005B"為"["的轉義        pageCount = tempContent.Length;        string outputContent = "";//要輸出的內容        if (pageCount <= 1)        {            outputContent = content; //文章內容            this.pnlPage.Visible = false;        }        else        {            string pageStr = "";//分頁字串            pageStr += "共 <span style='font-weight:bold'>" + pageCount + "</span> 頁  ";            if (currentPage != 1)            {                pageStr += " <a class='prev' href =" + pageUrl + "&page=" + (currentPage - 1) + ">上一頁</a> ";            }            for (int i = 1; i <= pageCount; i++)            {                if (i == currentPage)                    pageStr += ("<span class='active'> " + i + " </span>");                else                    pageStr += ("<a class='num' href =" + pageUrl + "&page=" + i + "> [" + i + "] </a>");            }            if (currentPage != pageCount)            {                pageStr += " <a class='next' href =" + pageUrl + "&page=" + (currentPage + 1) + ">下一頁</a> ";            }            this.lbl_page.Text = pageStr;//分頁的頁碼            outputContent = tempContent[currentPage - 1].ToString();        }        this.Literal1.Text = outputContent;//顯示文章的內容    }//此分頁方法是網路上尋找整理的

這種fckeditor分頁的方式有點死板,不知道各位大蝦有木有更好的方法,指教!!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.