public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagMode = TagMode.StartTagAndEndTag;
            output.TagName = "ul";

            TagBuilder ul = new TagBuilder("ul");

            ul.AddCssClass("pagination");
            output.MergeAttributes(ul);

            for (var pageNum = 1; pageNum <= TotalPages; pageNum++)
            {
                TagBuilder li = new TagBuilder("li");
                li.AddCssClass("page-item");
                if (pageNum == CurrentPage)
                {
                    li.AddCssClass("active");
                    TagBuilder span1 = new TagBuilder("span");
                    span1.AddCssClass("page-link");
                    span1.InnerHtml.Append($"{pageNum}");
                    li.InnerHtml.AppendHtml(span1);
                }
                else
                {
                    object     route = new { PageNumber = pageNum };
                    TagBuilder a;
                    a = _Generator.GeneratePageLink(
                        ViewContext,
                        linkText: pageNum.ToString(),
                        pageName: AspPage,
                        pageHandler: string.Empty,
                        protocol: string.Empty,
                        hostname: string.Empty,
                        fragment: string.Empty,
                        routeValues: route,
                        htmlAttributes: null
                        );
                    a.AddCssClass("page-link");

                    li.InnerHtml.AppendHtml(a);
                }

                output.Content.AppendHtml(li);
            }

            await base.ProcessAsync(context, output);

            return;
        }
Example #2
0
        private TagBuilder CreatePaginatorButton(string textForScreenReaders, string textToDisplay, int pageNum, bool clickable)
        {
            var tag = clickable
                    ? _Generator.GeneratePageLink(
                ViewContext,
                linkText: "",
                pageName: AspPage,
                pageHandler: string.Empty,
                protocol: string.Empty,
                hostname: string.Empty,
                fragment: string.Empty,
                routeValues: MakeRouteValues(pageNum),
                htmlAttributes: null
                )
                    : new TagBuilder("span");

            tag.AddCssClass("page-link");
            tag.AddAriaSpans(textForScreenReaders, textToDisplay);
            return(tag);
        }
        private TagBuilder LiName(string groupName, bool match)
        {
            if (!match)
            {
                groupName = $"{RemainingGroup}";
            }

            TagBuilder li = new TagBuilder("li");

            li.AddCssClass("page-item");
            if (groupName == CurrentGroup)
            {
                li.AddCssClass("active");
                TagBuilder span1 = new TagBuilder("span");
                span1.AddCssClass("page-link");
                span1.InnerHtml.Append($"{groupName}");
                li.InnerHtml.AppendHtml(span1);
            }
            else
            {
                object     route = new { GroupName = groupName };
                TagBuilder a;
                a = _Generator.GeneratePageLink(
                    ViewContext,
                    linkText: groupName,
                    pageName: AspPage,
                    pageHandler: string.Empty,
                    protocol: string.Empty,
                    hostname: string.Empty,
                    fragment: string.Empty,
                    routeValues: route,
                    htmlAttributes: null
                    );
                a.AddCssClass("page-link");

                li.InnerHtml.AppendHtml(a);
            }

            return(li);
        }
Example #4
0
 public TagBuilder GeneratePageLink(ViewContext viewContext, string linkText, string pageName, string pageHandler, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes)
 {
     return(_htmlGenerator.GeneratePageLink(viewContext, linkText, pageName, pageHandler, protocol, hostname, fragment, routeValues, htmlAttributes));
 }