asp.net使用FCK编辑器中的分页符实现长文章分页功能
更新时间:2024年07月01日 12:04:29 作者:smartsmile2012
这篇文章主要介绍了asp.net使用FCK编辑器中的分页符实现长文章分页功能,涉及asp.net字符串及分页操作的相关技巧,需要的朋友可以参考下
本文实例讲述了asp.net使用FCK编辑器中的分页符实现长文章分页功能。分享给大家供大家参考,具体如下:
<%@ 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)
{
//文章分页页码
int currentPage = Request["cpage"] == null ? 1 : Convert.ToInt32(Request["cpage"]);
//URL地址
string pageUrl = Request.Url.ToString();
ArticlePage(a, currentPage, pageUrl);
}
}
/// <summary>
///文章分页函数
/// </summary>
/// <param name="content">文章内容</param>
/// <param name="currentPage">当前页码</param>
/// <param name="pageUrl">当前页面地址</param>
protected void ArticlePage(string content, int currentPage, string pageUrl)
{
pageUrl = !pageUrl.Contains("?") ? pageUrl + "?" : pageUrl.Replace("&cpage=" + currentPage, "");
int pageCount = 0;//页数
content = content.Replace("<div style=\"page-break-after: always\"><span style=\"display: none\"> </span></div>", "[--page--]");//FCK在IE中生成的默认分页符,替换为自定义分页符
content = content.Replace("<div style=\"page-break-after: always\"><span style=\"display: none\"> </span></div>", "[--page--]");//FCK在FF中生成的默认分页符,替换为自定义分页符
string[] tempContent = System.Text.RegularExpressions.Regex.Split(content, "\\[--page--]"); //取得分页符 "\\["为"["的转义
pageCount = tempContent.Length;
string outputContent = "";//要输出的内容
if (pageCount <= 1)
{
outputContent = content; //文章内容
this.pnlPage.Visible = false;
}
else
{
string pageStr = "";//分页字符串
pageStr += "共<span class='count'>" + pageCount + "</span>页 ";
if (currentPage != 1)
{
pageStr += " <a class='prev' href =" + pageUrl + "&cpage=" + (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 + "&cpage=" + i + ">" + i + "</a>");
}
if (currentPage != pageCount)
{
pageStr += " <a class='next' href =" + pageUrl + "&cpage=" + (currentPage + 1) + ">下页</a>";
}
this.ltlPage.Text = pageStr;
outputContent = tempContent[currentPage - 1].ToString();
}
this.ltlContent.Text = outputContent;
}
}
更多关于asp.net相关内容感兴趣的读者可查看本站专题:《asp.net操作json技巧总结》、《asp.net字符串操作技巧汇总》、《asp.net操作XML技巧总结》、《asp.net文件操作技巧汇总》、《asp.net ajax技巧总结专题》及《asp.net缓存操作技巧总结》。
希望本文所述对大家asp.net程序设计有所帮助。
您可能感兴趣的文章:
- ASp.net下fckeditor配置图片上传最简单的方法
- asp.net FCKeditor自定义非空验证
- ASP.NET中FCKEDITOR在线编辑器的用法
- Asp.net FCKEditor 2.6.3 上传文件没有权限解决方法
- asp.net 为FCKeditor开发代码高亮插件实现代码
- ASP.NET 高性能分页代码
- Asp.Net中的三种分页方式总结
- asp.net Datalist控件实现分页功能
- asp.net 文章内容分页显示的代码
- asp.net repeater手写分页实例代码
- asp.net下Repeater使用 AspNetPager分页控件
- asp.net中gridview的查询、分页、编辑更新、删除的实例代码
相关文章
asp.net core集成ElasticSearch实现全文检索功能
索引是Elasticsearch中用于存储文档的容器,你可以使用Elasticsearch的REST API、官方客户端库(如NEST)或Kibana等工具来创建和管理索引,本文给大家介绍asp.net core集成ElasticSearch实现全文检索功能,感兴趣的朋友一起看看吧2024-08-08
ASP.NET中使用AspnetAccessProvider
ASP.NET中使用AspnetAccessProvider...2007-09-09
使用EF Code First搭建简易ASP.NET MVC网站并允许数据库迁移
这篇文章介绍了使用EF Code First搭建简易ASP.NET MVC网站并允许数据库迁移的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-09-09
asp.net显示相同数字相乘的结果,直到数值大于150为止
老师布置Insus.NET做的第二道题,题目如标题。感兴趣的网友也可以练习练习。现在Insus.NET的作答如下,但老师还没有看,因此答案是否正确或是最好的,还不能确定,只是供参考2012-05-05


最新评论