Exemple #1
0
        private void RenderPageLink(HtmlTextWriter writer, int pageNumber, string text, bool disabledOrActive)
        {
            if (disabledOrActive)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-link");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-link");

                if (_usePostBack && (String.IsNullOrEmpty(OnClientClient)))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, pageNumber.ToString()));
                }
                else if (_usePostBack)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClient + (!OnClientClient.EndsWith(";") ? ";" : "") + Page.ClientScript.GetPostBackEventReference(this, pageNumber.ToString()));
                }
                else if (!String.IsNullOrEmpty(OnClientClient))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClient);
                }

                writer.RenderBeginTag(HtmlTextWriterTag.A);
            }

            writer.Write(text);

            writer.RenderEndTag(); // A or Span tag.
        }
Exemple #2
0
        private void RenderButton(HtmlTextWriter writer, int pageNumber, string text, bool enabled, string ariaLabel)
        {
            if (!enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-item disabled");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-item");
            }

            if (_renderAsTable)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
            }
            else
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
            }

            // A tag - start
            if (!enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-link");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "page-link");

                if (_usePostBack && (String.IsNullOrEmpty(OnClientClient)))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(this, pageNumber.ToString()));
                }
                else if (_usePostBack)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClient + (!OnClientClient.EndsWith(";") ? ";" : "") + Page.ClientScript.GetPostBackEventReference(this, pageNumber.ToString()));
                }
                else if (!String.IsNullOrEmpty(OnClientClient))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClient);
                }

                if (!String.IsNullOrEmpty(ariaLabel))
                {
                    writer.AddAttribute("aria-label", ariaLabel);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.A);
            }

            writer.Write(text);
            writer.RenderEndTag(); // A or Span tag

            writer.RenderEndTag();
        }