예제 #1
0
        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            if (string.IsNullOrWhiteSpace(ImageUrl))
            {
                if (string.IsNullOrWhiteSpace(this.Icon))
                {
                    return;
                }

                this.CssClass = ":icon " + this.Icon.Trim().ToLowerInvariant();

                this.AddAttributes(writer, "ImageUrl", "Title");

                writer.RenderBeginTag(HtmlTextWriterTag.I);
            }
            else
            {
                this.CssClass = ":ui image";

                this.AddAttributes(writer);

                if (!Unit.IsEmpty(this.Width))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Width, this.Width.ToString());
                }

                if (!Unit.IsEmpty(this.Height))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Height, this.Height.ToString());
                }

                writer.RenderBeginTag(HtmlTextWriterTag.Img);
            }
        }
예제 #2
0
        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            this.AddAttributes(writer);

            if (!Unit.IsEmpty(this.Height))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
            }

            if (!Unit.IsEmpty(this.Width))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.Height.ToString());
            }

            switch (this.ScrollbarMode)
            {
            case Web.Controls.ScrollbarMode.Horizontal:
                writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowX, "scroll");
                break;

            case Web.Controls.ScrollbarMode.Vertical:
                writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowY, "scroll");
                break;

            case Web.Controls.ScrollbarMode.Both:
                writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "scroll");
                break;
            }

            writer.RenderBeginTag(this.GetListTagName());
        }
예제 #3
0
        public virtual Control ToHtmlControl()
        {
            Literal control = null;

            if (this.Dimension != Dimension.None)
            {
                this.CssClass = ":" + this.Dimension.ToString();
            }

            if (string.IsNullOrWhiteSpace(this.ImageUrl))
            {
                if (!string.IsNullOrWhiteSpace(this.Icon))
                {
                    var css = Utility.ResolveCssClass(":" + this.Icon, () => this.CssClass);
                    control = new Literal("i", "icon" + (string.IsNullOrWhiteSpace(css) ? "" : " " + css));
                }
            }
            else
            {
                control = new Literal("img", "image");
                control.SetAttributeValue("src", this.ImageUrl);

                if (!string.IsNullOrWhiteSpace(this.Placeholder))
                {
                    control.SetAttributeValue("alt", this.Placeholder);
                }

                if (!Unit.IsEmpty(this.Width))
                {
                    control.SetAttributeValue("width", this.Width.ToString());
                }

                if (!Unit.IsEmpty(this.Height))
                {
                    control.SetAttributeValue("height", this.Height.ToString());
                }

                if (!string.IsNullOrWhiteSpace(this.CssClass))
                {
                    control.CssClass = this.CssClass;
                }
            }

            if (control == null)
            {
                return(new Literal());
            }

            if (string.IsNullOrWhiteSpace(this.NavigateUrl))
            {
                return(control);
            }

            var container = new Literal("a", "image");

            container.SetAttributeValue("href", this.NavigateUrl);
            container.Controls.Add(control);
            return(container);
        }
예제 #4
0
        public virtual void ToHtmlString(TextWriter writer)
        {
            if (!string.IsNullOrWhiteSpace(this.NavigateUrl))
            {
                writer.Write("<a class=\"image\" href=\"{0}\">", this.NavigateUrl);
            }

            if (this.Dimension != Dimension.None)
            {
                this.CssClass = ":" + this.Dimension.ToString();
            }

            if (string.IsNullOrWhiteSpace(ImageUrl))
            {
                if (!string.IsNullOrWhiteSpace(this.Icon))
                {
                    this.CssClass = ":icon " + this.Icon.Trim();

                    writer.Write("<i");
                    this.WriteAttribute(writer, "class", this.CssClass);
                    writer.Write("></i>");
                }
            }
            else
            {
                writer.Write("<img");

                this.WriteAttribute(writer, "class", this.CssClass);
                this.WriteAttribute(writer, "alt", this.Placeholder);
                this.WriteAttribute(writer, "src", this.ImageUrl);

                if (!Unit.IsEmpty(this.Width))
                {
                    this.WriteAttribute(writer, "width", this.Width.ToString());
                }

                if (!Unit.IsEmpty(this.Height))
                {
                    this.WriteAttribute(writer, "height", this.Height.ToString());
                }

                writer.Write(" />");
            }

            if (!string.IsNullOrWhiteSpace(this.NavigateUrl))
            {
                writer.Write("</a>");
            }
        }