Fork me on GitHub

UrlPager Demo - Basic features

This sample demonstrates the besic features of the UrlPager control.
PageChanged event fired, current page index is 1
 First Prev 1 2 3 4 5 6 7 8 9 10 ... Next Last

Route definition:

    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;
        }
    }
}