Lately I’ve been playing around with Asp.Net Mvc. I’m trying to adapt the NerdDinner sample for a project I’m working on. The sample includes a class called PaginatedList<T>. PaginatedList<T> looks something like this:
public class PaginatedList<T> : List<T> { public int PageIndex { get; private set; } public int PageSize { get; private set; } public int TotalCount { get; private set; } public int TotalPages { get; private set; } }
My controller method looks something like this:
public ActionResult FindBusinessesByName(string businessName, int limit, int page) { BusinessRepository repository = new BusinessRepository(); PaginatedList<Business> paginatedBusinesses = new PaginatedList<Business>(repository.FindBusinessesByName(businessName), page, limit); return Json(paginatedBusinesses); }
I’m using jQuery to get a PaginatedList of businesses from my controller. I use the list of businesses to create an unordered list to display the business information. I haven’t played with jQuery or json serialization much so I was surprised to see that only the business data was returned. The extra properties on the PaginatedList were not. I dug around a bit and downloaded the newly released source for Mvc (woot!). I found the two lines in JsonResult.cs that do the serialization:
Read the rest of this entry »
About