Esempio n. 1
0
 public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInformation pagingInfo,
                                       Func<int, string> pageUrl)
 {
     var sb = new StringBuilder();
     for (var i = 1; i <= pagingInfo.TotalPages; i++)
     {
         var tag = new TagBuilder("a");
         tag.MergeAttribute("href", pageUrl(i));
         tag.InnerHtml = i.ToString(CultureInfo.InvariantCulture);
         if (i == pagingInfo.CurrentPage)
             tag.AddCssClass("selected");
         sb.AppendLine(tag.ToString());
     }
     return MvcHtmlString.Create(sb.ToString());
 }
Esempio n. 2
0
        public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInformation pagingInfo,
                                              Func<int, string> pageUrl)
        {
            var sb = new StringBuilder();
            for (var i = 1; i <= pagingInfo.TotalPages; i++)
            {
                var anchor = new TagBuilder("a");
                anchor.MergeAttribute("href", pageUrl(i));
                anchor.InnerHtml = i.ToString(CultureInfo.InvariantCulture);

                var item = new TagBuilder("li") { InnerHtml = anchor.ToString() };
                if (i == pagingInfo.CurrentPage)
                    item.MergeAttribute("class", "active");

                sb.AppendLine(item.ToString());
            }
            return MvcHtmlString.Create(sb.ToString());
        }