我正在使用分页列表来显示值列表。显示器工作正常。我使用提供的 Unobtrusive AJAX 来获取其他页面的数据。
这就是我的分页控件的外观。
@Html.PagedListPager(Model.CountryList, page => Url.Action("GetCountries", "Dashboard", new {page}), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions.ClassicPlusFirstAndLast, new AjaxOptions()
{
HttpMethod = "POST",
UpdateTargetId = "panel1",
OnSuccess = "onAjaxSuccess",
OnFailure = "onAjaxFailure"
}))
这很好用。
现在,我在页面中有一个文本框和一个下拉框,我想将其中存在的值与 Html 分页列表一起传递。
@Html.TextBox("SearchCountryName", new { name = "SearchCountryName", @class = "form-control", placeholder = "Search Country" })
@Html.DropdownList("Continent", ContinentList)
我的控制器代码是:
public PartialViewResult GetDashboardBody(string country,string continent,int? page)
{
}
我想做类似的事情
@Html.PagedListPager(Model.CountryList, page => Url.Action("GetCountries", "Dashboard", new {country = $("#SearchCountryName").val(),continent = $("#Continent").val(),page}), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions.ClassicPlusFirstAndLast, new AjaxOptions()
{
HttpMethod = "POST",
UpdateTargetId = "panel1",
OnSuccess = "onAjaxSuccess",
OnFailure = "onAjaxFailure"
}))
但这是行不通的。
那么我该如何使用 html.PagedList 将控件的当前值作为参数传递给操作方法呢?