我正在使用分页列表来显示值列表.显示效果很好.我使用提供的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将控件的当前值作为参数传递给action方法呢?