PageUS 2.0.0

dotnet add package PageUS --version 2.0.0
                    
NuGet\Install-Package PageUS -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PageUS" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PageUS" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PageUS" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PageUS --version 2.0.0
                    
#r "nuget: PageUS, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PageUS@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PageUS&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PageUS&version=2.0.0
                    
Install as a Cake Tool

PageUS

PageUS is a lightweight offset based pagination utility created to simplify paginated data handling in ASP.NET MVC apps — especially when working with stored procedures and server-side data sources.


⚡ Why PageUS?

Other pagination libraries often require fetching all records just to compute total pages — slowing down performance for large datasets.

PageUS solves this with:

  • Efficient calculation of Skip and Take values
  • Compatibility with stored procedures
  • Optional setting of total records (if returned from DB) for full UI controls
  • AJAX-based pagination UI generation with minimal setup

🔄 What's new?

PageUS v2.0.0 now supports pagination for IQueryable sources.


📦 Installation

dotnet add package PageUS

💻 Backend Example 1 (StoredProcedure call)

var pg = new PageUS(page, pageSize);

// Call your SP using Skip and Take
var results = _dbContext.spGetPagedResults(search, pg.Skip, pg.Take);

// If SP returns total record count
pg.TotalCount = results.FirstOrDefault()?.TotalRecords ?? 0;

var viewModel = new MyViewModel
{
    pageUs = pg,
    Applications1 = results.ToPageUSList(pg),
    TotalApplications = pg.TotalCount
};

💻 Backend Example 2 (IQueryable call)


// Call your SP using Skip and Take
var results = _dbContext.Table.ToPageUSResult(page, pageSize);

var viewModel = new MyViewModel
{
    Applications2 = results,
    TotalApplications = results.pageUS.TotalCount;
};


🗃️ Sample Stored Procedure Logic

SELECT *, COUNT(*) OVER() AS TotalRecords
FROM Applications
WHERE IsActive = 1
ORDER BY CreatedDate DESC
OFFSET @Skip ROWS
FETCH NEXT @Take ROWS ONLY;

🖼 View Example For Stored Procedure (Razor)

@using USPage;
@model MyViewModel
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
<link rel="stylesheet" href="Content/styles.css">  

<p>Total Applications: @Model.TotalApplications</p>
<div id = "results">
    <table>
    @foreach (var app in Model.Applications1)
    {
        <tr>
            <td>@app.property1</td>
            <td>@app.property2</td>
        </tr>
    }
    </table>
</div>

@Ajax.AjaxPagination(
    Model.pageUs,
    page => Url.Action("Index", new { page }),
    new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "results" }
)

🖼 View Example For IQuerable (Razor)

@using USPage;
@model MyViewModel
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
<link rel="stylesheet" href="Content/styles.css">  

<p>Total Applications: @Model.TotalApplications</p>
<div id = "results">
    <table>
    @foreach (var app in Model.Applications2.pageUSList)
    {
        <tr>
            <td>@app.property1</td>
            <td>@app.property2</td>
        </tr>
    }
    </table>
</div>

@Ajax.AjaxPagination(
    Model.Applications2,
    page => Url.Action("Index", new { page }),
    new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "results" }
)

📚 API Reference

PageUS Class

Property Description
Skip How many records to skip (for pagination)
Take PageSize + 1 (for next page detection)
CurrentPage The current page number
PageSize Items per page
NextPage true if there are more pages
TotalCount Optional total records (to enable "last page")
LastPage Computed if TotalCount is set

PageUSResult Class

Property Description
pageUS Contains pagination metadata like CurrentPage, total count, etc
pageUSList A list of data items for the current page

📄 License

MIT License


Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 236 7/10/2025
1.0.0 196 6/20/2025

Release Note: Added support for Iqueryable data source