Fork me on GitHub

UrlPager 示例 - 基本功能

本示例演示UrlPager的最基本功能。
PageChanged event fired, current page index is 17
 First Prev ... 11 12 13 14 15 16 17 18 19 20 Next Last

路由定义:

    routes.MapPageRoute("UrlPager_Basic", "urlpager/demos/{controller}/{action}/{id}", 
                "~/UrlPager/Demos/Basic.aspx", false, 
                new RouteValueDictionary { { "controller", "Basic" }, { "action", "page" }, { "id", null } }, 
                new RouteValueDictionary { { "controller", "Basic" }, { "action", "page" } });
   

Basic.aspx:

<%@Register Namespace="Webdiyer.WebControls" Assembly="Webdiyer.UrlPager" TagPrefix="webdiyer"%>
<div><asp:Label runat="server" ID="lb_txt" EnableViewState="false"></asp:Label>
<asp:Label runat="server" ID="lb_btn" EnableViewState="false"></asp:Label>
</div>
<webdiyer:UrlPager runat="server" id="pager1" RouteName="UrlPager_Basic" PageIndexParameterName="id" InheritsRouteValues="true" PagerItemTemplate="&nbsp;{0}"
                   TotalItemCount="198" OnPageChanged="PageChanged"></webdiyer:UrlPager> 
 

Basic.aspx.cs:

using System;
namespace Webdiyer.UrlPagerDemo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void PageChanged(object sender, EventArgs e)
        {
            lb_txt.Text = "PageChanged event fired, current page index is " + pager1.CurrentPageIndex;
        }
    }
}