views:

1805

answers:

2

Sorry this is my first question, don't know ho this works and i'm quite new to ASP.NET MVC. My action is:

    [AcceptVerbs(HttpVerbs.Get)]
    public ActionResult SearchResults(PersonSearch search, int? page)
    {
        // Assign the search results to the View
        ViewData["Results"] = new PaginatedList<Person>(
                 _searchService.FindPersons(personSearch), page ?? 0, 1);

        // Display the View and assign to it its Model (PersonSearch instance)
        return View("SearchResults", personSearch);
    }

Quite simple, the Model of SearchResults.aspx is an instance of PersonSearch; when the request for a new page arrive (a GET request), the action method should take it and compute the new results. Then i have to generate the previous/next links:

<%= Html.ActionLink("Next Page >", "SearchResults", routeValues) %>

If i use routeValues = ViewData.Model i can see the object properties passed correctly throw the address, but i can't add the "page" parameter.

How to? Many Thanks

A: 

It think it would be better to create another object with the correct values, instead of using (and potentially altering the current routevalues):

<%=Html.ActionLink("Next Page >", "SearchResults", new {
    search = this.Model,
    page = 1 //or whatever
}) %>
Lck
Gremo
Does not work...it passes the name of the class, not the key/values pairs corresponding to the object properties...
Gremo
+1  A: 

You need to override ToString().

KaneTW

related questions