使用 MVC PagedList 时如何添加查询字符串? [英] How do I add a querystring when using the MVC PagedList?
本文介绍了使用 MVC PagedList 时如何添加查询字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将查询字符串添加到下面的 Razor Helper PagedListPager?
How would I go about adding a query string to the Razor Helper PagedListPager below ?
@Html.PagedListPager( (IPagedList)Model.PartsList, page => Url.Action("Index", new { page }) )
推荐答案
您无需在 PagedListPager
中添加查询参数,而是在 Url.Action
中添加它们.
You don't add query parameters in PagedListPager
, you do them in Url.Action
.
以下是您代码的更新版本,我添加了查询参数 tag
.
Below is an updated version of your code, I've added a query parameter tag
.
Url.Action("Index", new { page, tag = 'asp' })
URL 将生成以下查询字符串
The URL would generate the following query string
?page=1&tag=asp
这是 PagedListPager
中相同的 Url.Action
:
@Html.PagedListPager(
(IPagedList)Model.PartsList,
page => Url.Action("Index", new { page, tag = 'asp' }))
这篇关于使用 MVC PagedList 时如何添加查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文