mvc contrib pager question
Let us say I have a bunch of checkboxes above my grid. posting their values (if selected) is no problem. I can also manipulate the the query strings that the pager uses for a GET request like this:
Html.Pager(Model.AssetsPagedList)
.First("First")
.Last("Last")
.Next("Next")
.Previous("Previous")
.Link(currentPage => Url.Action("Brow开发者_开发问答se", new {
page = currentPage,
searchTerm = Model.SearchModel.SearchTerm,
excludedWords = Model.SearchModel.ExcludedWords,
minPrice = Model.SearchModel.MinPrice,
maxPrice = Model.SearchModel.MaxPrice,
locationId = Model.SearchModel.LocationId,
catalogId = Model.SearchModel.CatalogId
}))
I am just wondering whether I can use the pager in a POST scenario. I guess on could change the links dynamically (after the checkboxes are changed) using javascript/jquery and still use GET. Or could change the links to submit buttons for POSTs. Did anyone use the pager like this?
Thanks.
C
Links cannot send POST requests. Only HTML forms or AJAX can. So either AJAXify your links or use forms with submit buttons (for this you will need to write a custom pager because the one used in MVCContrib uses links).
As far as AJAXifying the links is concerned:
$('.pagination a').live('click', function() {
$.post(this.href, function(result) {
// do something with the result
});
return false;
});
精彩评论