zoukankan      html  css  js  c++  java
  • 文章分页浏览

    在类似文章内容的页面中,当内容过于多的情况下,如果一直往下拉着看,很容易让用户感到疲劳,效果不好,所以需要分页显示出来,大致的思路看一下的例子:

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    public partial class _Default : System.Web.UI.Page
    {
        private string wz = "aabbccdde";
        private string diswz=null;
        private int pageCount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if (Request["id"] != null)
                {
                 
                    int id = Convert.ToInt32(Request["id"].ToString());
                    if (id != 5)
                    {
                        diswz = wz.Substring((id - 1) * 2, 2);
                    }
                    else
                    {
                        diswz = wz.Substring((id - 1) * 2);
                    }
                    this.Label1.Text = diswz;
                }
                else
                {
                    diswz = wz.Substring(0,2);
                    this.Label1.Text = diswz;
                }
                disLabel2(wz);
            }
        }
        public void disLabel2(string str)
        {
            int strCount = str.Length;
            //比如每页显示2个字符
            pageCount = ((strCount - 1) / 2) + 1;
            for (int i = 0; i < pageCount; i++)
            {
                this.Label2.Text += "<a href='?id="+(i+1)+"'>["+(i + 1)+"]</a>";
            }
        }
    }

    上面只是做个小小的测试,具体实施的时候我们有很多问题要考虑,下面的文件是分页的示例,可以下载下来看一下..

     /Files/shuang121/DevPagerSample.rar

    多思考,多创新,才是正道!
  • 相关阅读:
    Go 语言简介(下)— 特性
    Array.length vs Array.prototype.length
    【转】javascript Object使用Array的方法
    【转】大话程序猿眼里的高并发架构
    【转】The magic behind array length property
    【转】Build Your own Simplified AngularJS in 200 Lines of JavaScript
    【转】在 2016 年做 PHP 开发是一种什么样的体验?(一)
    【转】大话程序猿眼里的高并发
    php通过token验证表单重复提交
    windows 杀进程软件
  • 原文地址:https://www.cnblogs.com/shuang121/p/1970098.html
Copyright © 2011-2022 走看看