分页是Web应用程序中最常用到的功能之一,在ASP.NET中,虽然自带了一些可以分页的数据控件,但其分页功能并不尽如人意。本文对于这些数据控件的假分页暂且不表,如有不明白的同学请百Google度之。

本文中实现的分页控件是在手动分页基础上做的改善,将分页实现的逻辑部分和数据控件的绑定尽可能分开,以克服手工编写分页代码任务繁琐、代码重用率低等问题。

本文依旧是一粒粟子。

一、分页控件素颜

二、分页控件的实现

本文中将介绍两种将分页实现逻辑与数据控件绑定分离的实现方式:

  • 使用反射机制
  • 使用事件机制

1、基于反射机制的分页控件

源码:

PagingHelper.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PagingHelper.ascx.cs" Inherits="PagingHelper.Controls.PagingHelper" %>

<div style="width:100%">

    <asp:LinkButton ID="lbtnFirstPage" runat="server" CausesValidation="false" onclick="lbtnPage_Click"  >首页</asp:LinkButton>

    <asp:LinkButton ID="lbtnPrevPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >上一页</asp:LinkButton>

    &nbsp;第<asp:Label ID="lbPageIndex" runat="server" Text=""></asp:Label>

    页/共<asp:Label ID="lbTotalPages" runat="server" Text=""></asp:Label>

    页&nbsp;

    <asp:LinkButton ID="lbtnNextPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >下一页</asp:LinkButton>

    <asp:LinkButton ID="lbtnLastPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >尾页</asp:LinkButton>

</div>

PagingHelper.ascx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Reflection;

 

namespace PagingHelper.Controls

{

    public partial class PagingHelper : System.Web.UI.UserControl

    {

        #region 属性

        private int m_PageSize;

        public int PageSize         //每页显示记录数

        {

            set

            {

                m_PageSize = value;

            }

            get

            {

                if (m_PageSize.Equals(0))

                {

                    m_PageSize = 10;

                }

                return m_PageSize;

            }

        }

 

        private int m_PageIndex;

        public int PageIndex        //当前页页码

        {

            set

            {

                m_PageIndex = value;

            }

            get

            {

                if (m_PageIndex.Equals(0))

                {

                    m_PageIndex = 1;

                }

                return m_PageIndex;

            }

        }

 

        public int TotalItemCount   //记录总数

        {

            set;

            private get;

        }

 

        public string BindDataMethodName    //绑定数据的方法名

        {

            set;

            private get;

        }

        #endregion

 

        #region 受保护的方法

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                BindPagingHelperControl();

            }

        }

        protected void lbtnPage_Click(object sender, EventArgs e)

        {

            LinkButton lbtn = sender as LinkButton;

            ReBindData(lbtn.CommandArgument);

        }

        #endregion

 

        #region 公共方法

 

        #endregion

 

        #region 私有方法

        private void BindPagingHelperControl()

        {

            int totalPages = (TotalItemCount % PageSize) == 0 ? TotalItemCount / PageSize : TotalItemCount / PageSize + 1;

            //显示

            lbPageIndex.Text = PageIndex.ToString();

            lbTotalPages.Text = totalPages.ToString();

            //使能

            lbtnFirstPage.Enabled = PageIndex > 1;

            lbtnPrevPage.Enabled =  PageIndex > 1;

            lbtnLastPage.Enabled = PageIndex < totalPages;

            lbtnNextPage.Enabled = PageIndex < totalPages;

            //命令

            lbtnFirstPage.CommandArgument = "1";

            lbtnPrevPage.CommandArgument = (PageIndex - 1).ToString();

            lbtnNextPage.CommandArgument = (PageIndex + 1).ToString();

            lbtnLastPage.CommandArgument = totalPages.ToString();

        }

        private void ReBindData(string pageIndex)

        {

            PageIndex = int.Parse(pageIndex);

            Object obj = null;  //空间所在的容器

            if (base.Parent is HtmlForm)

            {

                obj = this.Page;

            }

            else if (base.Parent is ContentPlaceHolder)

            {

                obj = this.Page.Master.Page;

            }

            else

            {

                obj = base.Parent;

            }

            MethodInfo methodInfo = obj.GetType().GetMethod(BindDataMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            methodInfo.Invoke(obj, null);

            BindPagingHelperControl();

        }

        #endregion

 

    }

}

Demo:

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PagingHelper.Default" %>

 

<%@ Register src="Controls/PagingHelper.ascx" tagname="PagingHelper" tagprefix="uc1" %>

 

<!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>

        <asp:GridView ID="gvDemo" runat="server">

        </asp:GridView>

        <br />

        <uc1:PagingHelper ID="PagingHelper1" runat="server" PageSize="2" />

    </div>

    </form>

</body>

</html>

Default.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

 

namespace PagingHelper

{

    public partial class Default : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            GvDemoBind();

        }

 

        protected void GvDemoBind()

        {

            string sql = @"SELECT * FROM tb_user";

            string sqlCount = @"SELECT COUNT(*) FROM tb_user ";

            int itemStart = (PagingHelper1.PageIndex - 1) * PagingHelper1.PageSize;

            sql += string.Format(" LIMIT {0},{1}",itemStart,PagingHelper1.PageSize);

            gvDemo.DataSource = SQLHelper.ExecuteDataTable(sql).DefaultView;

            gvDemo.DataBind();

            PagingHelper1.TotalItemCount = Convert.ToInt32(SQLHelper.ExecuteScalar(sqlCount));

            PagingHelper1.BindDataMethodName = "GvDemoBind";

        }

    }

}

2、基于事件机制的分页控件

源码:

PagingHelper.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PagingHelper.ascx.cs" Inherits="PagingHelper_V2.Controls.PagingHelper" %>

<div style="width:100%">

    <asp:LinkButton ID="lbtnFirstPage" runat="server" CausesValidation="false" onclick="lbtnPage_Click"  >首页</asp:LinkButton>

    <asp:LinkButton ID="lbtnPrevPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >上一页</asp:LinkButton>

    &nbsp;第<asp:Label ID="lbPageIndex" runat="server" Text=""></asp:Label>

    页/共<asp:Label ID="lbTotalPages" runat="server" Text=""></asp:Label>

    页&nbsp;

    <asp:LinkButton ID="lbtnNextPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >下一页</asp:LinkButton>

    <asp:LinkButton ID="lbtnLastPage" runat="server" CausesValidation="false"  onclick="lbtnPage_Click" >尾页</asp:LinkButton>

    &nbsp;转到

    <asp:TextBox ID="txtGoto" runat="server" Width="32px"></asp:TextBox>

    页<asp:Button ID="btnGoto" runat="server" Text="确定" onclick="btnGoto_Click" />

</div>

PagingHelper.ascx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

 

namespace PagingHelper_V2.Controls

{

    public partial class PagingHelper : System.Web.UI.UserControl

    {

        #region 属性

        private int m_PageSize;

        public int PageSize         //每页显示记录数

        {

            set

            {

                m_PageSize = value;

            }

            get

            {

                if (m_PageSize.Equals(0))

                {

                    m_PageSize = 10;

                }

                return m_PageSize;

            }

        }

 

        private int m_PageIndex;

        public int PageIndex        //当前页页码

        {

            set

            {

                m_PageIndex = value;

            }

            get

            {

                if (m_PageIndex.Equals(0))

                {

                    m_PageIndex = 1;

                }

                return m_PageIndex;

            }

        }

 

        public int TotalItemCount   //记录总数

        {

            set;

            private get;

        }

 

        #endregion

 

        #region 受保护的方法

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                BindPagingHelperControl();

            }

        }

        protected void lbtnPage_Click(object sender, EventArgs e)

        {

            LinkButton lbtn = sender as LinkButton;

            ReBindData(int.Parse(lbtn.CommandArgument));

        }

        protected void btnGoto_Click(object sender, EventArgs e)

        {

            int gotoPageIndex = PageIndex;

            if (int.TryParse(txtGoto.Text, out gotoPageIndex))

            {

                if (gotoPageIndex < 1 || gotoPageIndex > int.Parse(lbTotalPages.Text))

                {

                    Response.Write("<script>alert('此页面不存在!')</script>");

                }

                else

                {

                    if (!gotoPageIndex.Equals(int.Parse(lbPageIndex.Text)))

                    {

                        ReBindData(gotoPageIndex);

                    }

                }

            }

            else

            {

                Response.Write("<script>alert('请输入正确的页码!')</script>");

            }

 

        }

        #endregion

 

        #region 公共方法

 

        #endregion

 

        #region 私有方法

        private void BindPagingHelperControl()

        {

            int totalPages = (TotalItemCount % PageSize) == 0 ? TotalItemCount / PageSize : TotalItemCount / PageSize + 1;

            //显示

            lbPageIndex.Text = PageIndex.ToString();

            lbTotalPages.Text = totalPages.ToString();

            txtGoto.Text = PageIndex.ToString();

            //使能

            lbtnFirstPage.Enabled = PageIndex > 1;

            lbtnPrevPage.Enabled = PageIndex > 1;

            lbtnLastPage.Enabled = PageIndex < totalPages;

            lbtnNextPage.Enabled = PageIndex < totalPages;

            //命令

            lbtnFirstPage.CommandArgument = "1";

            lbtnPrevPage.CommandArgument = (PageIndex - 1).ToString();

            lbtnNextPage.CommandArgument = (PageIndex + 1).ToString();

            lbtnLastPage.CommandArgument = totalPages.ToString();

        }

        private void ReBindData(int pageIndex)

        {

            PageIndex = pageIndex;

            OnPageIndexChanged(new EventArgs());

            BindPagingHelperControl();

        }

        #endregion

 

        #region 事件

        public delegate void PageIndexChangedEventHandler(object sender, EventArgs e);

        public event PageIndexChangedEventHandler PageIndexChanged;

        protected virtual void OnPageIndexChanged(EventArgs e)

        {

            PageIndexChangedEventHandler handler = PageIndexChanged;

            if (handler != null)

            {

                handler(this, e);

            }

        }

        #endregion

 

        

    }

}

Demo:

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PagingHelper_V2.Default" %>

 

<%@ Register src="Controls/PagingHelper.ascx" tagname="PagingHelper" tagprefix="uc1" %>

 

<!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>

        <asp:GridView ID="gvDemo" runat="server">

        </asp:GridView>

        &nbsp;

        <uc1:PagingHelper ID="PagingHelper1" runat="server" PageSize="2" OnPageIndexChanged="PagingHelper1_OnPageIndexChanged" />

    </div>

    </form>

</body>

</html>

Default.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace PagingHelper_V2

{

    public partial class Default : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            GvDemoBind();

        }

 

        protected void GvDemoBind()

        {

            string sql = @"SELECT * FROM tb_user";

            string sqlCount = @"SELECT COUNT(*) FROM tb_user ";

            int itemStart = (PagingHelper1.PageIndex - 1) * PagingHelper1.PageSize;

            sql += string.Format(" LIMIT {0},{1}", itemStart, PagingHelper1.PageSize);

            gvDemo.DataSource = SQLHelper.ExecuteDataTable(sql).DefaultView;

            gvDemo.DataBind();

            PagingHelper1.TotalItemCount = Convert.ToInt32(SQLHelper.ExecuteScalar(sqlCount));

            

        }

 

        protected void PagingHelper1_OnPageIndexChanged(object sender, EventArgs e)

        {

            GvDemoBind();

        }

    }

}

三、总结

比较两种实现方式,基于事件机制的实现更符合ASP.NET服务器控件的style。

好!那就参照园子里的分页使用基于事件机制的方式再做一个控件作为总结。

源码:

PagingHelper.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PagingHelper.ascx.cs" Inherits="PagingHelper_V3.Controls.PagingHelper" %>

<style type="text/css">

    a.LinkButtonDefault{text-align:center;text-decoration:none;margin-right:1px;padding:2px 4px;}

    a.LinkButtonBlue{background: #ebebeb;text-align:center;text-decoration:none;margin-right:1px;padding:2px 4px;}

    a.LinkButtonYellow { background-color:#ccc; color:#000fff; font-weight:bold;text-align:center;text-decoration:none;margin-right:1px;padding:2px 4px;}

</style>

<div style="width:100%">

    共<asp:Label ID="lbTotalPages" runat="server" ForeColor="#fff"></asp:Label>页:

    <asp:LinkButton ID="lbtnFirstPage" runat="server" CausesValidation="false" CssClass="LinkButtonDefault" onclick="lbtnPage_Click" >首页</asp:LinkButton>

    <asp:LinkButton ID="lbtnPrevPage" runat="server" CausesValidation="false" CssClass="LinkButtonDefault" onclick="lbtnPage_Click" >上一页</asp:LinkButton>

    <asp:Repeater ID="rptPageNumber" runat="server">

        <ItemTemplate>

            <asp:LinkButton ID="lbtnPageNumber" runat="server" CausesValidation="false" Width="16px" onclick="lbtnPage_Click"

                 CssClass='<%# Convert.ToInt32(Container.DataItem)==PageIndex?"LinkButtonYellow":"LinkButtonBlue"%>' CommandArgument='<%# Container.DataItem %>'>

<%
   1: #Container.DataItem 
%>

            </asp:LinkButton>

        </ItemTemplate>

    </asp:Repeater>

    <asp:LinkButton ID="lbtnNextPage" runat="server" CausesValidation="false" CssClass="LinkButtonDefault"  onclick="lbtnPage_Click" >下一页</asp:LinkButton>

    <asp:LinkButton ID="lbtnLastPage" runat="server" CausesValidation="false" CssClass="LinkButtonDefault"  onclick="lbtnPage_Click" >尾页</asp:LinkButton>

</div>

PagingHelper.ascx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace PagingHelper_V3.Controls

{

    public partial class PagingHelper : System.Web.UI.UserControl

    {

        #region 属性

        private int m_PageSize;

        public int PageSize         //每页显示记录数

        {

            set

            {

                m_PageSize = value;

            }

            get

            {

                if (m_PageSize.Equals(0))

                {

                    m_PageSize = 10;

                }

                return m_PageSize;

            }

        }

 

        private int m_PageIndex;

        public int PageIndex        //当前页页码

        {

            set

            {

                m_PageIndex = value;

            }

            get

            {

                if (m_PageIndex.Equals(0))

                {

                    m_PageIndex = 1;

                }

                return m_PageIndex;

            }

        }

 

        public int TotalItemCount   //记录总数

        {

            set;

            private get;

        }

 

        #endregion

 

        #region 受保护的方法

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                BindPagingHelperControl();

            }

        }

        protected void lbtnPage_Click(object sender, EventArgs e)

        {

            LinkButton lbtn = sender as LinkButton;

            ReBindData(int.Parse(lbtn.CommandArgument));

        }

        #endregion

 

        #region 公共方法

 

        #endregion

 

        #region 私有方法

        private void BindPageNum(int totalPages)

        {

            int startPageIndex = 1, endPageIndex = 10;

            if (totalPages < endPageIndex)

            {

                endPageIndex = totalPages;

            }

            else

            {

                startPageIndex = (PageIndex > 5) ? PageIndex - 5 : startPageIndex;

                int result = (startPageIndex + 9) - totalPages;

                if (result > 0)

                {

                    endPageIndex = totalPages;

                    startPageIndex -= result;

                }

                else

                {

                    endPageIndex = startPageIndex + 9;

                }

            }

            BindPageNum(startPageIndex, endPageIndex);

        }

        private void BindPageNum(int startPageIndex, int endPageIndex)

        {

            int[] pages = new int[endPageIndex - startPageIndex + 1];

            int index = 0;

            for (int i = startPageIndex; i <= endPageIndex; i++)

            {

                pages[index] = i;

                index++;

            }

            rptPageNumber.DataSource = pages;

            rptPageNumber.DataBind();

        }

        private void BindPagingHelperControl()

        {

            int totalPages = (TotalItemCount % PageSize) == 0 ? TotalItemCount / PageSize : TotalItemCount / PageSize + 1;

            //显示

            lbTotalPages.Text = totalPages.ToString();

            BindPageNum(totalPages);

            //使能

            lbtnFirstPage.Enabled = PageIndex > 1;

            lbtnPrevPage.Enabled = PageIndex > 1;

            lbtnLastPage.Enabled = PageIndex < totalPages;

            lbtnNextPage.Enabled = PageIndex < totalPages;

            //命令

            lbtnFirstPage.CommandArgument = "1";

            lbtnPrevPage.CommandArgument = (PageIndex - 1).ToString();

            lbtnNextPage.CommandArgument = (PageIndex + 1).ToString();

            lbtnLastPage.CommandArgument = totalPages.ToString();

        }

        private void ReBindData(int pageIndex)

        {

            PageIndex = pageIndex;

            OnPageIndexChanged(new EventArgs());

            BindPagingHelperControl();

        }

        #endregion

 

        #region 事件

        public delegate void PageIndexChangedEventHandler(object sender, EventArgs e);

        public event PageIndexChangedEventHandler PageIndexChanged;

        protected virtual void OnPageIndexChanged(EventArgs e)

        {

            PageIndexChangedEventHandler handler = PageIndexChanged;

            if (handler != null)

            {

                handler(this, e);

            }

        }

        #endregion

    }

}

Web用户控件开发--分页控件的更多相关文章

  1. jQuery控件之分页控件-- kkpager v1.3使用简介

    js分页展示控件,传入简单参数就能使用的分页效果控件 在线测试链接: http://pgkk.github.io/kkpager/example/pager_test.html http://pgkk ...

  2. DEV控件的分页控件,实现勾选复选框

    /// <summary> /// 单元格的点击事件 /// </summary> /// <param name="sender"></ ...

  3. 用C#编写ActiveX控件,开发浏览器控件,注册ActiveX 控件

    用C#编写ActiveX控件,开发浏览器控件,注册ActiveX 控件用C#编写ActiveX控件 开发浏览器控件这是本控件开发完成后的一个简单应用.我们可以利用它以本地文件夹为单位来批量更新服务器的 ...

  4. 基于jquery扩展漂亮的分页控件(ajax)

    分页控件式大家在熟悉不过的控件,很多情况下都需要使用到分页控件来完成列表数据加载操作,在很多分页控件中有的编写麻烦,有的应用扩展比较复杂,有的分页控件样式比较丑陋,有的分页控件用户体验操作比较简单等等 ...

  5. asp.net分页控件库

    AspNetPager分页控件 AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的 ...

  6. 【NET】Winform分页控件初探

    public partial class WinFormPager : UserControl { ; /// <summary> /// 当前页 /// </summary> ...

  7. 《ASP.NET1200例》ListView 控件与DataPager控件的结合<一>

    分页     在前一部分开始时介绍的原 HTML 设计中内含分页和排序,所以根据规范完整实现该网格的任务尚未完成.我们先分页,然后再排序. ListView 控件中的分页通过引入另一个新控件 Data ...

  8. PCHMI工控组态开发视频教程

    PCHMI是一款适合所有PLC工程师快速上手工控组态开发的控件 下面是视频教程链接 PCHMI工控组态 02-按钮的使用 PCHMI工控组态 03-数据显示器使用 PCHMI工控组态 04-标签控件的 ...

  9. 用C#开发ActiveX控件,并使用web调用

    入职差不多两个月了,由学生慢慢向职场人做转变,也慢慢的积累知识,不断的更新自己.最近的一个项目里边,涉及到的一些问题,因为SDK提供的只是winform才能使用了,但是有需求咱们必须得完成啊,所以涉及 ...

随机推荐

  1. js 开源k线图开发库

    https://github.com/andredumas/techan.js/wiki http://techanjs.org/ A visual, stock charting (Candlest ...

  2. python 解析top文件格式

    top - 16:14:35 up 2 days, 3:04, 7 users, load average: 2.22, 1.84, 1.77 Tasks: 512 total, 2 running, ...

  3. http put post请求区别

    1.RESTful API REST: Representational State Transfer url 对应服务器上的一种资源,e.g. 数据,图片等,所以url 中只含有名词,通过HTTP动 ...

  4. PRM路径规划算法

    路径规划作为机器人完成各种任务的基础,一直是研究的热点.研究人员提出了许多规划方法:如人工势场法.单元分解法.随机路标图(PRM)法.快速搜索树(RRT)法等.传统的人工势场.单元分解法需要对空间中的 ...

  5. 【树莓派+.NET MF打造视频监控智能车】控制篇(树莓派)

    对已经具备一定Linux基础的人来说,树莓派学习起来应该非常简单自然.在他们眼中,树莓派就是一个简易版的,卡通版的Linux而已.但是对我这样一个早已习惯微软技术生态系统的人或者初学者来说,要实现一个 ...

  6. OPML文件

    # -*- coding: cp936 -*-#python 27#xiaodeng#OPML文件 #大纲处理标记语言其实建立在颗脱战标记语言之上的标记语言#也叫文件扩展名#是建立在XML之上的一种文 ...

  7. 设置visual studio的小技巧

    设置 Visual Studio 方法 1.设置关闭快捷键 Ctrl + W:关闭当前文档窗口 Ctrl + Q:关闭所有文档窗口 设置方法:工具-->选项-->键盘:在显示命令包含中输入 ...

  8. (原)torch,caffe,python中读入数据的默认范围

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6554388.html 之前torch(image.load).caffe(默认的).python(使用 ...

  9. Linux下Setuid命令! 转载

    Linux下Setuid命令! 转载  在Linux系统中每个普通用户都可以更改自己的密码,这是合理的设置. 问题是:用户的信息保存在文件/etc/passwd中,用户的密码保存在文件/etc/sha ...

  10. 蛋疼的经历--wireshark不能启动的问题

    事情是这样子的,最近新入职,安装了wireshark,,,在急需要其观察数据包结构,,,,写代码时,,,,卡了,,,我的天!!! 刚开始是提示说,找不到动态链接库api-ms-win-crt-runt ...