liveBook · Manning

Page-model attribute

As explained in Pro ASP.NET Core 7, Tenth Edition

A page-model attribute is the sample tag helper attribute that supplies a paging model to the page-link tag helper.

The page-model attribute supplies a PagingInfo object to a page-link tag helper. Razor finds it on a div and asks PageLinkTagHelper to replace that element with navigation links. section 7.4.1

Add paging links to a view

After the view uses ProductsListViewModel, add <div page-model="@Model.PagingInfo" page-action="Index"></div>. Requesting the application then produces links such as http://localhost:5000/?productPage=2. section 7.4.1

http://localhost:5000/?productPage=2

Inspect a generated paging URL to see how navigation moves between catalog pages. section 7.4.1

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains attribute discovery and transformation, while implementation details remain in PageLinkTagHelper.
Examples
Uses a ProductsListViewModel, page-action="Index", and a productPage=2 URL.
What it assumes
Assumes a PagingInfo-bearing view model and a registered PageLinkTagHelper.
What you can do after
Apply it via Razor markup to render page links from a ProductsListViewModel.
How it connects
Links Razor views, tag helpers, view models, PagingInfo, and pagination.

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.