Documentation > CMS Template API Library > PaginatedLinks > HasPrevious()

HasPrevious

Used to check if there are anymore links prior the current page.

public System.Boolean HasPrevious()

Code Example

C#

Sample:

            
            List<Asset> children = asset.GetFileList();    
            PaginateResult result = Util.Paginate(children, 5);
            
            if(result.PaginatedLinks.HasPrevious())
            {
              Out.WriteLine("<a href=\"{0}\">&lt; Previous</a> | ", result.PaginatedLinks.Previous);
            }
            
            int i = 0;
            foreach (PageLink link in result.PaginatedLinks)
            { 
              if(!link.IsCurrent)
              {
                Out.WriteLine("<a href=\"{0}\">{1}</a> | ", link.ToString(), ++i);
              }
              else
              {
                Out.WriteLine("{0} | ", ++i);
              }
            }
            if(result.PaginatedLinks.HasNext())
            {
              Out.WriteLine("<a href=\"{0}\">Next &gt;</a> | ", result.PaginatedLinks.Next);
            }
            
            

Connect with Crownpeak