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?
It's not exactly what you want, but you can figure it out.
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, ie
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.