How pages storing querystring values ​​in ASP.Net Mvc 2

I am using the pager provided by Martijn Boland to implement paging in my Asp.Net Mvc 2 application.

My form uses a GET method to send all parameters to a queue, this is a search form with multiple form elements.

<% using (Html.BeginForm("SearchResults", "Search", FormMethod.Get))
       {%>

      

In SearchResults view I am trying to implement paging:

<div class="pager">
    <%= Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount, 
        new { Request.QueryString })%>
</div>

      

There are some overloads in Html.Pager that I am not very clear on how to use. Request.QueryString makes the querystring like this:

http://localhost:1155/Search/SearchResults?QueryString=Distance%3D10%26txtZip%3D%26cb&page=2

      

If it isn't?

http://localhost:1155/Search/SearchResults?Distance=20&txtZip=10021&page=2

      

+2


source to share


1 answer


My guess would be to write your pager like this

<%= Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount,  new { Distance = Request["Distance"], txtZip = Request["txtZip"] })%>

      



but that's just a guess, I've never used this ...

Edit: See ASP.Net MVC. Storing action parameters between postbacks so you need to create RouteValueDictionary

from a QueryString that is NameValueCollection

.

+1


source







All Articles