Exemple #1
0
        public override string ToHtml()
        {
            StringBuilder html = new StringBuilder();

            html.Append('<').Append(ElementNames.Anchor);

            if (!string.IsNullOrEmpty(Id))
            {
                html.Append(" id=\"").Append(Id).Append('\"');
            }

            if (!string.IsNullOrEmpty(Name))
            {
                html.Append(" name=\"").Append(Name).Append('\"');
            }

            html.Append(" href=\"").Append(_href).Append('\"');

            if (!string.IsNullOrWhiteSpace(Style))
            {
                html.Append(" style=\"").Append(Style).Append('\"');
            }

            // self is default target of anchor. So do not display self target
            if (_target != AnchorTarget.Self)
            {
                html.Append(" target=\"").Append(_target.ToHtml()).Append('\"');
            }

            html.Append(">");
            html.Append(_text);

            if (InnerElements != null)
            {
                foreach (IHtmlElement element in InnerElements)
                {
                    html.Append(element.ToHtml());
                }
            }

            html.Append("</").Append(ElementNames.Anchor).Append('>');

            return(html.ToString());
        }