Expression Evaluation Time: ms / Round trip: ms
Custom Paging Control
22. Mar
by Dario Category:

This short blog post shows you how to implement your custom paging control to use with the Composite Web Part.

There is a PageInfo object that you can access when you have enabled paging (PageSize > 0) in the Composite Web Part.

Instead of using the default paging control with <PagingControl/> you can define an expression variable that renders your custom HTML.

public string GetPagingHtml()
    IPageInfo pi = (IPageInfo)Expr("PageInfo");

    if (pi.HasMorePages)
        return String.Format("Page {0} - <a href='#' Event='PageLink' StartIndex='{1}'>Next</a>",
            pi.StartIndex / pi.PageSize + 1, pi.StartIndex + pi.PageSize);
        return String.Format("Page {0} - No more pages.", pi.StartIndex / pi.PageSize + 1);

In the FooterTemplate then use {Acme.Paging.GetPagingHtml()} instead of <PagingControl/>.

IPageInfo provides all required information such as StartIndex, RowCount, PageSize etc.

The Composite Web Part does the event binding after each AJAX callback that occurs in event of paging. Therefore you have to add an Event='PageLink' attribute to all the HTML elements that represents a link to page back, forward or jump to a specific page. Further the element needs an attribute StartIndex with the index of the first row of that page.

10.09.2013 01:30
As I understand, this code should be in a Composite User control? I created one - Test.Paging.xml. Pasted the code and used it in the FooterTemplate of the Composite Web Part like this - Test.Paging.GetPagingHtml but I receive an null reference exception. pi is null. I have Pagging enabled and set to 2. What is wrong?
11.09.2013 08:40
Ok the problem was with the issue, when number of items is less or equal to a page size. I think this is quite important thing and should be described here.

This blog is about technical and non-technical aspects of the product MatchPoint and other SharePoint topics.

If you would like to post an article or if you have an idea for a post, please contact us.

Matthias Weibel
09.04.2018 01:12
Link is updated and works now. | Goto Post
09.04.2018 12:21
Link doesn't work. Could anyone explain what does... | Goto Post
14.03.2018 02:05
Hi Markus
We I use the config for SiteCollectionSe... | Goto Post
Reto Jeger
04.10.2017 09:15
Hello Reiner,
Thanks for pointing out the missing ... | Goto Post
29.09.2017 09:56
Hi, I downloaded the ZIP-file for MatchPoint Versi... | Goto Post