Knowledgebase Home Page  >  SearchUnit
Search the Knowledge Base
How can I create my own next/previous page links? (C#)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=155&catId=54

Options

Print this page
Email this to a friend
Besides simply modifying the Footer (or Header) template of the SearchResult control, or the SearchResult properties NextPageLinkText and PreviousPageLinkText you can also create your own links from scratch using this inline code
 
 
<a href="<%# SearchResult1.PreviousPageLink %>" ><%= SearchResult1.ResultsPage>1 ? "Previous" :"" %></a>

<a href="<%# SearchResult1.NextPageLink %>" ><%= (SearchResult1.ResultsPage * 10 < SearchResult1.NumberOfResults) ? "Next" :"" %></a>
 
 
This gives the opportunity to change not only the text and surrounding HTML (as the methods described at the top) but also the internal aspects of the link.
 
The properties SearchResult1.PreviousPageLink and SearchResult1.NextPageLink provide the postback javascript required to make the page navigation work.
 
 
In order to modify the "link block" (linked digits 1 through 10) add the following code to the codebehind class
 

protected string LinkBlock

{

get

{

string pageLinksBlock = "";

int start,end, noPages = (int) Math.Ceiling( ((float)SearchResult1.NumberOfResults) / ((float)SearchResult1.NumberOfResultsPerPage));

start = SearchResult1.ResultsPage-5;

end = SearchResult1.ResultsPage+5;

//current page close to the beginning

if(SearchResult1.ResultsPage<=5)

{

start = 1;

end = 10;

}

//current page close to the end

if(SearchResult1.ResultsPage>(noPages-5))

{

start = SearchResult1.ResultsPage-5-(noPages-SearchResult1.ResultsPage);

end = noPages;

}

for(int i=start; i<=end; i++)

{

if( (i>0) && (i<=noPages) )

{

if(i==SearchResult1.ResultsPage)

pageLinksBlock += i+" ";

else

pageLinksBlock += "<a href=\"javascript:"+this.GetPostBackEventReference(SearchResult1, "Page"+i)+"\">_"+i+"</a> ";

}

}

return pageLinksBlock ;

}

}

 

Then call this code by adding the following to the FooterTemplate

  <%= LinkBlock %>

The links generated by the property LinkBlock can be easily modified as required.

 


Related Questions:

Attachments:

No attachments were found.