博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
史上最简短的文章长内容的代码,转
阅读量:4350 次
发布时间:2019-06-07

本文共 1066 字,大约阅读时间需要 3 分钟。

史上最简短的文章长内容的分页代码,非常实用,大家来一起收藏啊!!!

通过研究网上有关新闻文章的分页代码,得出还是手动的插入分页符是最佳方案,因为这样可以控制什么地方该分页,
网上有几种版本都不实用,比如根据文章内容的字数来自动分页,或者清除html等格式(关键有时候这个内容本身就是鱼龙混杂的,再好的正规也会列不出)。同时在网上也看到有手动插入分页符来实现的,大多数代码都有错,而且一大长串,看得头昏,我最喜欢最简短的代码就能实现某个功能。
如有比此代码更简段的,欢迎填上来,分享分享。
================================================
//写一个类
public class SplictPage
  {
  public static string bind(string content, string Id)
  {
  string thisnr = "";
  string thispage = "";
  string[] temp = content.Trim().Split('㊣');
  if (System.Web.HttpContext.Current.Request.QueryString["page"] == null)
  {
  thisnr = "<div>" + temp[0] + "</div>";
  }
  else
  {
  thisnr = "<div>" + temp[System.Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString["page"]) - 1] + "</div>";
  }
  if (temp.Length > 1)
  {
  for (int i = 0; i <= temp.Length - 1; i++)
  {
  thispage += "<a href=?x_id=" + Id + "&page=" + (i + 1) + ">[" + (i + 1) + "]</a> ";
  }
  }
  return thisnr + thispage;
  }
  }
----------------------
//调用
this.txtcontent.Text = SplictPage.bind(mydr["x_nr"].ToString(), "3");

转载于:https://www.cnblogs.com/wdw31210/archive/2012/01/30/2331760.html

你可能感兴趣的文章
[扫描线]POJ2932 Coneology
查看>>
全局变量与全局静态变量的区别
查看>>
oo第一次作业总结
查看>>
EMC队列 发件人为空 From Address: <>
查看>>
多路复用IO模型 IO multiplexing
查看>>
升级WordPress
查看>>
蒙蒙的Git
查看>>
js方法遇到就记录
查看>>
Codeforces-868C. Qualification Rounds(状压)
查看>>
iReport采用JDBC的方式连接Oracle
查看>>
MongoDB 数据库的可视化
查看>>
AOP中的相关概念
查看>>
【转】内存溢出、内存泄漏、内存越界、缓冲区溢出、栈溢出
查看>>
监控系统信息模块psutil
查看>>
python tokenizer
查看>>
类的成员修饰符
查看>>
A - Race to 1 Again
查看>>
HDU 1754 I hate it
查看>>
实现滑动出现删除按钮的代码
查看>>
windows提权exp列表
查看>>