Adding paging to SearchResults user control in aspx template

Tim G. asked on September 21, 2018 11:25

I've created a search results template and added the 'SearchResults' user control so my code looks something like this:

<uc1:SearchResults runat="server" ID="ucSearchResults" Indexes="MySite-SiteSearch" />

How do I bind a unipager to these results to add paging? I'd expected to do something like the below but this doesn't seem to work:

<cms:UniPager ID="pgUniPagerControl" runat="server" PageControl="ucSearchResults" PageSize="10" >
    <PreviousPageTemplate>
        <a href="<%# Eval("PreviousURL") %>" class="button-small w-button">Previous page</a>
    </PreviousPageTemplate>
    <NextPageTemplate>
        <a href="<%# Eval("NextURL") %>" class="button-small w-button">Next page</a>
    </NextPageTemplate>
</cms:UniPager>

Recent Answers


Brenden Kehren answered on September 21, 2018 16:27

You assign the pager control the ID of the smart search control.

pgUniPagerControl.PageControl = "ucSearchResults";

There are most likely other properties you'll need to set but this should get your pager connected to the results. Smart Search results may have a different set of properties since it's a little more unique than a standard repeater but this should help.

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on September 21, 2018 16:30 (last edited on September 21, 2018 16:30)

I'm already assigning that property above in the control:

<cms:UniPager ID="pgUniPagerControl" runat="server" PageControl="ucSearchResults" PageSize="10" >

But I still don't see anything. Any other ideas?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 21, 2018 16:54 (last edited on September 21, 2018 16:55)

I'd be willing to bet it has to do with the smart search results control then. Make sure you load the results on each page load. Also set your paging number to something rediculiouly low like 2 and see if anything shows.

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on September 21, 2018 17:19

I've tried both of these things - is there any reasonable documentation on how to get paging working nicely with search results? It seems a pretty standard task to want paging with previous and next buttons which hide when not needed doesn't it?

I'd accept a solution using transformations if that's the only way.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 21, 2018 17:42

The difference is the webparts. A repeater webpart is different than a smart search webpart. So you might want to look at the underlying controls which make those webparts up to figure out how each work.

In this case upon inspecting the smart search results webpart, it is loading the a user control from /CMSModules/SmartSearch/Controls/SmartSearch.ascx. You might try setting it backwards like this:

srchResults.UniPagerControl = "pgUniPagerControl";

As I stated every webpart is different even though some use the same underlying user controls.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.