views:

38

answers:

1

I want to send the selected page value on the querystring while navigating through paging.

The URL that is generated for paging is like this:

Link/Index?page=2
Link/Index?page=3

But on my URL it only shows Link/Index and performs the Ajax call. But if I disable my Javascript and then navigate through paging it gets Postback and has a URL like

Link/Index?page=2

Which is perfect. But I want this type of URL in an Ajax call as well.

How can I do this? Issue is if we navigate through pages when Javascript is enable it shows Link/Index and when user goes to page no 2 then 3 then 4 and press back button it goes to press page instead of page 3 then page 2.

Here is the code that generates the page links:

    <%= Ajax.Pager(
        new AjaxOptions { 
            UpdateTargetId = "divGrid", LoadingElementId = "divLoading" 
        }, 
        ViewData.Model.PageSize, 
        ViewData.Model.PageNumber, 
        ViewData.Model.TotalItemCount, 
        new { controller = "LinkManagement", action = "Index" }
    )%>
+1  A: 

This isn't really an issue with the pager, but that's how ajax works. Because you haven't created a new full page request, nothing is stored in history to allow the back button to persist the ajax calls too. You need to use something like jquery.history (http://tkyk.github.com/jquery-history-plugin/) or jquery address api (http://www.asual.com/jquery/address/samples/api/#/section/?id=2.2).

Matthew Abbott