Ejemplo n.º 1
0
        private HtmlString BuildPageList(int start, int stop)
        {
            var ul = new TagMaker("ul", "pagination");

            for (var i = start; i <= stop; i++)
            {
                var li = new TagMaker("li", "page page-number");
                var a  = new TagMaker("a");

                a.MergeAttribute("href", $"{Url}?page={i}");
                a.MergeAttribute("title", $"Click to go to page {i}");
                a.Text = i.ToString();

                ExtendForAjax(a);

                if (i == PageCurrent)
                {
                    li.AddCssClass("active");
                }

                li.Children.Add(a);
                ul.Children.Add(li);
            }

            return(new HtmlString(ul.ToString()));
        }
Ejemplo n.º 2
0
        private HtmlString BuildArrowList(int current)
        {
            var ul        = new TagMaker("ul", "pagination");
            var left      = new TagMaker("li", "page page-arrow");
            var right     = new TagMaker("li", "page page-arrow");
            var leftArrow = new TagMaker("a")
            {
                Text = "&laquo;"
            };
            var rightArrow = new TagMaker("a")
            {
                Text = "&raquo;"
            };

            if (current > 1)
            {
                leftArrow.MergeAttribute("href", $"{Url}?page={current - 1}");
                leftArrow.MergeAttribute("title", "Go to the previous page");
            }
            else
            {
                left.AddCssClasses("disabled");
                leftArrow.Attributes.Add("disabled", "disabled");
            }

            if (current < PageCount)
            {
                rightArrow.Attributes.Add("href", $"{Url}?page={current + 1}");
                rightArrow.MergeAttribute("title", "Go to the next page");
            }
            else
            {
                right.AddCssClasses("disabled");
                rightArrow.Attributes.Add("disabled", "disabled");
            }

            ExtendForAjax(leftArrow);
            ExtendForAjax(rightArrow);

            left.Children.Add(leftArrow);
            right.Children.Add(rightArrow);
            ul.Children.Add(left);
            ul.Children.Add(right);

            return(new HtmlString(ul.ToString()));
        }