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.

June 2015 (3)
1-5 (32) 
6 days ago
I'm trying to import tag with Matchpoint Tag Impor... | Goto Post
Markus Lindenmann
08.04.2016 05:34
The release notes for MatchPoint and MatchPoint Sn... | Goto Post
Sandra Perz
08.04.2016 03:43
Do you provide a download of the release notes som... | Goto Post
07.04.2015 08:57
Hi Tobias,
I works just fine. I overlooked the lin... | Goto Post
Tobias Pfanner
07.04.2015 08:53
Hello Reiner
I tried the download using a 'regular... | Goto Post