Exemplo n.º 1
0
        public static void DoWebControlAddAttributes(WebControl webControl, IWebControlAccessor webControlAccessor, HtmlTextWriter writer)
        {
            if (webControl.ID != null)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, webControl.ClientID);
            }

            var s = webControl.AccessKey;

            if (!String.IsNullOrEmpty(s))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, s);
            }

            if (!webControl.Enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }

            var n = webControl.TabIndex;

            if (n != 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, n.ToString(NumberFormatInfo.InvariantInfo));
            }

            s = webControl.ToolTip;
            if (!String.IsNullOrEmpty(s))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, s);
            }

            if (webControlAccessor.TagKey == HtmlTextWriterTag.Span || webControlAccessor.TagKey == HtmlTextWriterTag.A)
            {
                if ((webControl.BorderStyle != BorderStyle.NotSet || !webControl.BorderWidth.IsEmpty || !webControl.Height.IsEmpty || !webControl.Width.IsEmpty))
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block");
                }
            }

            if (webControl.ControlStyleCreated && !webControl.ControlStyle.IsEmpty)
            {
                webControl.ControlStyle.AddAttributesToRender(writer, webControl);
            }

            var atrColl = webControl.Attributes;
            var keys    = atrColl.Keys.GetEnumerator();

            while (keys.MoveNext())
            {
                var attrName = (string)(keys.Current);
                writer.AddAttribute(attrName, atrColl[attrName]);
            }
        }
        public static void DoWebControlAddAttributes(WebControl webControl, IWebControlAccessor webControlAccessor, HtmlTextWriter writer)
        {
            if(webControl.ID != null)
                writer.AddAttribute(HtmlTextWriterAttribute.Id, webControl.ClientID);

            var s = webControl.AccessKey;
            if(!String.IsNullOrEmpty(s))
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, s);

            if(!webControl.Enabled)
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");

            var n = webControl.TabIndex;
            if(n != 0)
                writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, n.ToString(NumberFormatInfo.InvariantInfo));

            s = webControl.ToolTip;
            if(!String.IsNullOrEmpty(s))
                writer.AddAttribute(HtmlTextWriterAttribute.Title, s);

            if(webControlAccessor.TagKey == HtmlTextWriterTag.Span || webControlAccessor.TagKey == HtmlTextWriterTag.A) {
                if((webControl.BorderStyle != BorderStyle.NotSet || !webControl.BorderWidth.IsEmpty || !webControl.Height.IsEmpty || !webControl.Width.IsEmpty))
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block");
            }

            if(webControl.ControlStyleCreated && !webControl.ControlStyle.IsEmpty)
                webControl.ControlStyle.AddAttributesToRender(writer, webControl);

            var atrColl = webControl.Attributes;
            var keys = atrColl.Keys.GetEnumerator();
            while(keys.MoveNext()) {
                var attrName = (string)(keys.Current);
                writer.AddAttribute(attrName, atrColl[attrName]);
            }
        }