I am using paged list to display a list of values. The display works fine. I use the provided Unobtrusive AJAX to get the data for the other pages.
This is how my paged control looks.
@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"
}))
This works fine.
Now I have a textbox and a drop down box in the page and I want to pass values present in those along with the Html Paged list.
@Html.TextBox("SearchCountryName", new { name = "SearchCountryName", @class = "form-control", placeholder = "Search Country" })
@Html.DropdownList("Continent", ContinentList)
My controller code is :
public PartialViewResult GetDashboardBody(string country,string continent,int? page)
{
}
I want to do something like
@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"
}))
But this does not work.
So how do I go about passing the current value of the controls to the action method as parameters using html.PagedList?