Guest User

Untitled

a guest
Jul 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /?Column=ColumnName&Direction=Ascending
  2.  
  3. Html.ActionLink("View 10", "Index", new { pageSize = 10 })
  4.  
  5. /?PageSize=10
  6.  
  7. /?Column=ColumnName&Direction=Ascending&PageSize=10
  8.  
  9. Html.ActionLink(
  10. "View 10",
  11. "Index",
  12. new {
  13. Column = Request["Column"],
  14. Direction = Request["Direction"],
  15. pageSize = 10
  16. }
  17. )
  18.  
  19. Html.PaginateLink("View 10", 10)
  20.  
  21. public static class HtmlExtensions
  22. {
  23. public static MvcHtmlString PaginateLink(
  24. this HtmlHelper helper,
  25. string linkText,
  26. int pageSize
  27. )
  28. {
  29. var query = helper.ViewContext.HttpContext.Request.QueryString;
  30. var values = query.AllKeys.ToDictionary(key => key, key => (object)query[key]);
  31. values["pageSize"] = pageSize;
  32. var routeValues = new RouteValueDictionary(values);
  33. return helper.ActionLink(linkText, "Index", routeValues);
  34. }
  35. }
Add Comment
Please, Sign In to add comment