Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4050380
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:03:45+00:00 2026-05-20T14:03:45+00:00

To implement a search results page on a Sitecore 6.3.1 site, I created a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:03:46+00:00Added an answer on May 20, 2026 at 2:03 pm

    Here’s the solution I ultimately went with. It’s not pretty, but it does work:

    /// <summary>
    ///   Fixes any HyperLinks that point to the layout .aspx file to point to
    ///     the Sitecore context item.
    /// </summary>
    /// <param name="control">
    ///   The control to fix (its child controls will be processed).
    /// </param>
    protected void FixLayoutHyperLinks(Control control)
    {
      var currentPath = LinkManager.GetItemUrl(Sitecore.Context.Item);
      foreach (Control c in control.Controls)
      {
        foreach (Control d in c.Controls)
        {
          if (d is HyperLink)
          {
            var link = (HyperLink)d;
    
            /* Change just the path of the existing URL.
             * @see http://stackoverflow.com/questions/5276324/modifying-just-the-path-part-of-a-hyperlinks-navigateurl-in-c/5276375#5276375
             */
            var url = new UriBuilder(Request.Url.Host + link.NavigateUrl);
            url.Path = currentPath;
    
            /* For consistency (and because ASP.Net will strip the leading
             *  "http://" during PreRender), do not add the hostname/schema to
             *  the resulting URI.
             * 
             * @see http://sobot-software.blogspot.com/2009/02/asphyperlink-navigateurl-problem.html
             */
            link.NavigateUrl = url.Uri.PathAndQuery;
          }
        }
      }
    }
    

    I use it like so:

    private void Page_Load(object sender, EventArgs e)
    {
      ...
    
      var Pager = MyListView.FindControl("Pager") as DataPager;
      FixLayoutHyperLinks(Pager);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Implement a link back to a search result page from one of its clicked
I am trying to implement country search in my dummy application. Initially on home
i want to implement a small search engine , i have index page where
I have a website where i want to implement search functionality.So i added the
I am trying to implement pagination in my search results with Yii. I have
I'm creating a site like craigslist and need to implement a search feature where
I've used Lucene.net to implement search functionality (for both database content and uploaded documents)
How could I implement an image preview feature like Google image search result, when
Trying to implement a search similar to here .This searches properties based on city,locality,property
I wanted to implement a search feature for my web app. I choose Haystack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.