views:

243

answers:

3

I like to implement a paging in my asp.net mvc(C#) application like the one in blogger(blogspot.com).

The Paging should look like:

   `New Posts                      Home                    Older Posts`

The Page should contain the number of items configurable.

Any ideas on this?

A: 

It's not exactly what you want, but you can figure it out.

http://mgolchin.blogspot.com/2009/06/mvc-datapager.html

Mehdi Golchin
A: 

The easiest way to do this would be to find the next and previous articles/blogs in your controller and then pass these into the view using ViewData, i.e.

ViewData["NextPost"] = Model.GetNextPost();
ViewData["PrevPost"] = Model.GetPrevPost();

Then simply display these in your view:

<ul>
    <li><%= Html.Action("New posts", new { Action = "View", Id = (Post)ViewData["NextPost"].Id }) %></li>
    <li><%= Html.Action("Home", new { Action = "Home" }) %></li>
    <li><%= Html.Action("Old posts", new { Action = "View", Id = (Post)ViewData["PrevPost"].Id }) %></li>
</ul>

You will need to style the ul to make it look nice. If you then want to make this piece of code reusable, you could put the display code in a partial view.

theouteredge
A: 

I have followed the implementation from nerddinner for now, as @Greco said.

Prasad