mirror of
https://github.com/rudollee/LearningMVC.git
synced 2025-06-08 00:16:14 +00:00
33 lines
842 B
C#
33 lines
842 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.Text;
|
|
using SportsStore.WebUI.Models;
|
|
|
|
namespace SportsStore.WebUI.HtmlHelpers
|
|
{
|
|
public static class PagingHelpers
|
|
{
|
|
public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo, Func<int, string> pageUrl)
|
|
{
|
|
StringBuilder result = new StringBuilder();
|
|
for (int i = 1; i <= pagingInfo.TotalPages; i++)
|
|
{
|
|
TagBuilder tag = new TagBuilder("a");
|
|
tag.MergeAttribute("href", pageUrl(i));
|
|
tag.InnerHtml = i.ToString();
|
|
if (i == pagingInfo.CurrentPage)
|
|
{
|
|
tag.AddCssClass("selected");
|
|
tag.AddCssClass("btn-primary");
|
|
}
|
|
tag.AddCssClass("btn btn-default");
|
|
result.Append(tag.ToString());
|
|
}
|
|
|
|
return MvcHtmlString.Create(result.ToString());
|
|
}
|
|
}
|
|
} |