zoukankan      html  css  js  c++  java
  • 史上最简短的文章长内容的代码,转

    史上最简短的文章长内容的分页代码,非常实用,大家来一起收藏啊!!!
    通过研究网上有关新闻文章的分页代码,得出还是手动的插入分页符是最佳方案,因为这样可以控制什么地方该分页,
    网上有几种版本都不实用,比如根据文章内容的字数来自动分页,或者清除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");





    http://topic.csdn.net/u/20120119/03/06e41f86-c8f5-423f-90f2-f160d30d8aa6.html?40566

  • 相关阅读:
    正则表达式 1
    14 同步 1
    14 线程属性
    14 线程状态
    14 线程
    window.location.hostname与 window.location.host 区别
    泛型 的通配符类型 extends super
    svn拷贝一个项目作为新项目
    List Collections sort
    && 和 || 逻辑运算符
  • 原文地址:https://www.cnblogs.com/wdw31210/p/2331760.html
Copyright © 2011-2022 走看看