长文章分页+fck修改分页符
来源:互联网 发布:finale 软件 编辑:程序博客网 时间:2024/05/21 08:14
1.长文章分页
protected void Page_Load(object sender, EventArgs e)
{
if (!int.TryParse(Request.Params["id"] as string, out this.Id))
{
return;
}
Label1.Text = OutputBySize1(model.Content);
}
public string OutputBySize1(string p_strContent)//長文章手动分页函数
{string m_strRet = "";
string[] str = StringSplit(p_strContent, "<div>{zwr}</div>");
int m_intCurrentPage = 1;//設置第一頁為初始頁
int m_intTotalPage = 0;
if (str.Length > 1)
{
//文章有几页
m_intTotalPage = str.Length;
if (Request.QueryString["ps"] != null)
{//set Current page number
try
{//处理不正常的地址栏的值
m_intCurrentPage = Convert.ToInt32(Request.QueryString["ps"]);
if (m_intCurrentPage > m_intTotalPage)
m_intCurrentPage = m_intTotalPage;
}
catch
{
m_intCurrentPage = 1;
}
}
m_strRet += str[m_intCurrentPage - 1];
string m_strPageInfo = "";
for (int i = 1; i <= m_intTotalPage; i++)
{
if (i == m_intCurrentPage)
{
m_strPageInfo += "<span class=\"current\">" + i + "</span>";
}
else
{
m_strPageInfo += " <a href=\"newscon" + Id + "_" + i + ".html\">" + i + "</a> ";
}
}
if (str.Length > 1)
{
if (m_intCurrentPage > 1)
m_strPageInfo = "<a href=\"newscon" + Id + "_" + (m_intCurrentPage - 1) + ".html\">上一页</a>" + m_strPageInfo;
else
m_strPageInfo = "<span class=\"disabled\">上一页</span>" + m_strPageInfo;
if (m_intCurrentPage < m_intTotalPage)
m_strPageInfo += "<a href=\"newscon" + Id + "_" + (m_intCurrentPage + 1) + ".html\">下一页</a>";
else
m_strPageInfo += "<span class=\"disabled\">下一页</span>";
//輸出顯示各個頁碼
fenye = m_strPageInfo.ToString();
}
}
else
{
m_strRet += p_strContent;
}
return m_strRet;
}
#region 拆分字符串
public string[] StringSplit(string strSource, string strSplit)
{
string[] strtmp = new string[1];
int index = strSource.IndexOf(strSplit, 0);
if (index < 0)
{
strtmp[0] = strSource;
return strtmp;
}
else
{
strtmp[0] = strSource.Substring(0, index);
return StringSplit(strSource.Substring(index + strSplit.Length), strSplit, strtmp);
}
}
#endregion
#region 采用递归将字符串分割成数组
/// <summary>
/// 采用递归将字符串分割成数组
/// </summary>
/// <param name="strSource"></param>
/// <param name="strSplit"></param>
/// <param name="attachArray"></param>
/// <returns></returns>
private string[] StringSplit(string strSource, string strSplit, string[] attachArray)
{
string[] strtmp = new string[attachArray.Length + 1];
attachArray.CopyTo(strtmp, 0);
if (index < 0)
{
strtmp[attachArray.Length] = strSource;
return strtmp;
}
else
{
strtmp[attachArray.Length] = strSource.Substring(0, index);
return StringSplit(strSource.Substring(index + strSplit.Length), strSplit, strtmp);
}
}
#endregion
2.fck分页符修改
FKC默认添加的分页符为:<div style="page-break-after: always"><span style="display: none"> </span></div>
对文章的分页,我是运用String.split("分页符")方法,将文章以分页符为分割点,返回一个String类型的数组,但是双引号不能够相互嵌套,split()方法中的参数就没办法设置。
如何修改默认的分页符:
找到js文件:在/fckeditor/editor/js/目录下,需要修改的有两个js文件:fckeditorcode_ie.js(针对IE浏览器的配置)、fckeditorcode_gecko.js(针对非IE浏览器的配置)。
在js文件中找到如下代码,并做修改:
var FCKPageBreakCommand=function()
{this.Name='PageBreak';};
FCKPageBreakCommand.prototype.Execute=function()
{FCKUndo.SaveUndoStep();
var e=FCK.EditorDocument.createElement('DIV'); //这里是创建<div>标签,此处不用修改
e.style.pageBreakAfter='always'; //这里是为<div>添加样式,把它删掉;
e.innerHTML='<span style="DISPLAY:none"> </span>';
//这里是在<div>中添加的内容,修改一下; 我的是修改为e.innerHTML=' '; 也就是仅有一个空格;
保存,重新添加文章,添加文章时看不出变化,保存看查看数据,分页符的位置变为: <div> </div>
为文章分页就可以用split("<div> </div>")方法进行拆分显示了;
- 长文章分页+fck修改分页符
- asp.net利用FCK编辑器中的分页符 完成长文章分页
- fck 文章分页
- asp.net 使用FCK分页符大文章分页
- 长文章分页,手动输入分页符
- 长文章分页代码
- asp 长文章分页
- asp长文章分页
- 长文章分页
- php长文章分页
- 给长文章分页
- 长文章分页
- asp长文章分页
- asp长文章分页
- 长文章分页
- html长文章分页
- ueditor 长文章分页
- FCK编辑器 修改插入分页符,给力啊。
- erlang浅谈(4)-OTP
- 函数调用 堆栈
- 关于时间一系列类的说明和用法
- 音乐网
- hdu acm steps 2.2.4
- 长文章分页+fck修改分页符
- android使用http协议实现文件的上传
- hdu acm steps 2.2.5
- 各种数据库默认端口汇集
- EXT窗口
- VIM编辑代码时的一些技巧
- ARCHIVELOG模式下用户管理恢复联机重做日志文件(2)——当前活动组所有成员全部损坏!
- session.createQuery()与createSQLQuery()区别