I have a paged list using unobtrusive ajax that looks like this.
@Html.PagedListPager(Model, page => Url.Action("Images", "Admin", new { imageLibrary = image.ImageLibrary, page }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions()
{ InsertionMode = InsertionMode.Replace, UpdateTargetId = "imagesContainer" }))
My controller looks like this:
public ActionResult Images(ImageModels image, int? page, string imageLibrary)
{
// do stuff here
}
I was trying to pass a model to my controller, so instead of imageLibrary = image.ImageLibrary
, I should have only needed to pass image = imageModel
, but when I pass the model itself, the controller gets a null value (yes the model name was spelled correctly). When I try to get a property of the model and pass it to the controller (that's the imageLibrary = image.ImageLibrary
) the controller receives both the model and the imageLibrary
string value! This works fine for the end result, I just don't understand why it works, and I shouldn't have to pass the string value imageLibrary
to my controller - especially if I'm not really using it.
Any insight on this would be appreciated.