bool AddAttributesForSpan(HtmlTextWriter writer) { if (HasAttributes) { AttributeCollection attributes = Attributes; ICollection k = attributes.Keys; string [] keys = new string [k.Count]; k.CopyTo(keys, 0); foreach (string key in keys) { if (!IsInputOrCommonAttr(key)) { continue; } if (common_attrs == null) { common_attrs = new AttributeCollection(new StateBag()); } common_attrs [key] = Attributes [key]; attributes.Remove(key); } if (attributes.Count > 0) { attributes.AddAttributes(writer); return(true); } } return(false); }
void RenderInput(HtmlTextWriter w, bool enabled) { if (ClientID != null && ClientID.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); } w.AddAttribute(HtmlTextWriterAttribute.Type, render_type); string nameAttr = NameAttribute; if (nameAttr != null && nameAttr.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Name, nameAttr); } InternalAddAttributesToRender(w, enabled); AddAttributesToRender(w); if (Checked) { w.AddAttribute(HtmlTextWriterAttribute.Checked, "checked", false); } if (AutoPostBack) { Page page = Page; string onclick = page != null?page.ClientScript.GetPostBackEventReference(GetPostBackOptions(), true) : String.Empty; onclick = String.Concat("setTimeout('", onclick.Replace("\\", "\\\\").Replace("'", "\\'"), "', 0)"); if (common_attrs != null && common_attrs ["onclick"] != null) { onclick = ClientScriptManager.EnsureEndsWithSemicolon(common_attrs ["onclick"]) + onclick; common_attrs.Remove("onclick"); } w.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick); } if (AccessKey.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey); } if (TabIndex != 0) { w.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString(NumberFormatInfo.InvariantInfo)); } if (common_attrs != null) { common_attrs.AddAttributes(w); } if (inputAttributes != null) { inputAttributes.AddAttributes(w); } w.RenderBeginTag(HtmlTextWriterTag.Input); w.RenderEndTag(); }
void RenderInput(HtmlTextWriter w, bool enabled) { if (ClientID != null && ClientID.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); } w.AddAttribute(HtmlTextWriterAttribute.Type, render_type); string nameAttr = NameAttribute; if (nameAttr != null && nameAttr.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Name, nameAttr); } InternalAddAttributesToRender(w, enabled); #if NET_2_0 AddAttributesToRender(w); if (inputAttributes != null) { inputAttributes.AddAttributes(w); } #endif if (Checked) { w.AddAttribute(HtmlTextWriterAttribute.Checked, "checked", false); } if (AutoPostBack) { #if NET_2_0 string onclick = Page.ClientScript.GetPostBackEventReference(GetPostBackOptions(), true); onclick = String.Concat("setTimeout('", onclick.Replace("\\", "\\\\").Replace("'", "\\'"), "', 0)"); w.AddAttribute(HtmlTextWriterAttribute.Onclick, BuildScriptAttribute("onclick", onclick)); #else w.AddAttribute(HtmlTextWriterAttribute.Onclick, BuildScriptAttribute("onclick", Page.ClientScript.GetPostBackEventReference(this, String.Empty))); w.AddAttribute("language", "javascript", false); #endif } if (AccessKey.Length > 0) { w.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey); } if (TabIndex != 0) { w.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString(NumberFormatInfo.InvariantInfo)); } if (common_attrs != null) { common_attrs.AddAttributes(w); } w.RenderBeginTag(HtmlTextWriterTag.Input); w.RenderEndTag(); }
void RenderLabel(HtmlTextWriter w) { string text = Text; if (text.Length > 0) { if (labelAttributes != null) { labelAttributes.AddAttributes(w); } w.AddAttribute(HtmlTextWriterAttribute.For, ClientID); w.RenderBeginTag(HtmlTextWriterTag.Label); w.Write(text); w.RenderEndTag(); } }
public void Deny_Unrestricted() { // nothing else is required AttributeCollection ac = new AttributeCollection(bag); Assert.AreEqual(0, ac.Count, "Count"); Assert.IsNotNull(ac.CssStyle, "CssStyle"); ac["mono"] = "monkey"; Assert.AreEqual("monkey", ac["mono"], "this"); Assert.IsNotNull(ac.Keys, "Keys"); ac.Add("monkey", "mono"); ac.AddAttributes(writer); ac.Clear(); ac.Remove("mono"); ac.Render(writer); }