将属性添加到分页 url.action?
Add attribute to pagination url.action?
我正在尝试将 ID
之类的属性添加到分页中,以便我可以代表它在 JS 中执行一些操作。
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { page }))
当我尝试添加时,它显示在 URL 中。有人知道在这种情况下如何设置 ID
吗?
如有任何帮助,我们将不胜感激。
我想通了。
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { ID = ViewContext.ViewBag.CheckingAccountId, page, PageSize = Model.PageSize } ))
需要添加 ViewContext
以便从 viewbag
... 中获取 ID,并在控制器中再次声明该 ID。
或
使用 JQuery
<div id="Paginator">
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { ID = ViewContext.ViewBag.CheckingAccountId, page, PageSize = Model.PageSize } ))
</div>
Jquery函数
function bind() {
$('#Paginator').on('click', 'a', function() {
$.ajax({
url: this.href,
type: 'GET',
cache: false,
success: function(result) {
$('#TableContainerId').html(result);
bind(); // called this java script code again
}
});
return false;
});
});
我正在尝试将 ID
之类的属性添加到分页中,以便我可以代表它在 JS 中执行一些操作。
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { page }))
当我尝试添加时,它显示在 URL 中。有人知道在这种情况下如何设置 ID
吗?
如有任何帮助,我们将不胜感激。
我想通了。
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { ID = ViewContext.ViewBag.CheckingAccountId, page, PageSize = Model.PageSize } ))
需要添加 ViewContext
以便从 viewbag
... 中获取 ID,并在控制器中再次声明该 ID。
或 使用 JQuery
<div id="Paginator">
@Html.PagedListPager(Model, page => Url.Action("ConfirmCases", new { ID = ViewContext.ViewBag.CheckingAccountId, page, PageSize = Model.PageSize } ))
</div>
Jquery函数
function bind() {
$('#Paginator').on('click', 'a', function() {
$.ajax({
url: this.href,
type: 'GET',
cache: false,
success: function(result) {
$('#TableContainerId').html(result);
bind(); // called this java script code again
}
});
return false;
});
});