Hi
I'm not sure if this is the best approach so hoping for some advice. I have a pager that updates the page using ajax. I'd like the user to be able to select the size of the page they require I'm doing this with a form and some jquery which calls an action method that sets the Session["PageSize"] value which is used to determine how many records are displayed. If the Session value is empty I have a default set as well. This worked great in Firefox but for some reason IE wont use the session value and always reverts to the default??
private const int DefaultPageSize = 25;
private int PageSize
{
get
{
// We check if there is a value in session state for pagesize if not we return the default value
if (Session[ViewKeysProvider.PageSize] == null)
return DefaultPageSize;
// We'll try and parse the session value for the pagesize as an int if this fails pass the default value back
int result;
return int.TryParse(Session[ViewKeysProvider.PageSize].ToString(), out result) ? result : DefaultPageSize;
}
set { PageSize = value; }
}
[HttpPost]
public ActionResult SetPageSize(FormCollection collection)
{
Session[ViewKeysProvider.PageSize] = collection[ViewKeysProvider.PageSize];
return RedirectToAction("Sales", new { page = collection[ViewKeysProvider.CurrentPage] });
}
My question is have I got the right approach here (something about using the redirects smells a little)? What am I missing why is IE being such a pain.. I've stepped through with the debugger and can see the session value being changed.
Any help appreciated.