To implement a search results page on a Sitecore 6.3.1 site, I created a content item at /sitecore/content/Home/Search
and added a Search Results sublayout to its presentation controls. The sublayout uses a ListView to display the search results and a DataPager to handle pagination.
Here is an excerpt from Search Results.ascx
:
<asp:ListView ID="SearchResults" runat="server"> <LayoutTemplate> <asp:DataPager ID="Pager" QueryStringField="page" runat="server"> <Fields> <asp:NumericPagerField ButtonCount="10" /> </Fields> </asp:DataPager> <asp:Placeholder ID="itemPlaceholder" runat="server" /> </LayoutTemplate> ... </asp:ListView>
Note that the DataPager's QueryStringField
parameter is set to a non-empty value.
When the sublayout is rendered, the search results and pagination controls appear correctly. However, the pagination hyperlinks go to the wrong URL. Instead of going to the page URL, they link to the layout's URL.
For example, if the user clicks on the link for page 2, one would expect his browser to go to e.g., http://www.example.com/Search.aspx?query=xyz&page=2. But his browser actually links to http://www.example.com/layouts/Generic%20Browser%20Layout.aspx?query=xyz&page=2.
Where is the DataPager getting the bogus URL, and how do I fix this?