// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
#endif
{
string render_type;
+ AttributeCollection common_attrs;
#if NET_2_0
AttributeCollection inputAttributes;
[WebCategory ("Appearance")]
public virtual TextAlign TextAlign
{
- get {
- object o = ViewState["TextAlign"];
-
- if (o == null) {
- return (TextAlign.Right);
- } else {
- return ((TextAlign)o);
- }
- }
+ get { return (TextAlign) ViewState.GetInt ("TextAlign", (int)TextAlign.Right); }
set {
if (value != TextAlign.Left &&
value != TextAlign.Right) {
[DefaultValue ("")]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
- public string ValidationGroup
+ public virtual string ValidationGroup
{
get { return ViewState.GetString ("ValidationGroup", String.Empty); }
set { ViewState["ValidationGroup"] = value; }
}
}
+ static bool IsInputOrCommonAttr (string attname)
+ {
+ attname = attname.ToUpper (CultureInfo.InvariantCulture);
+ switch (attname) {
+ case "VALUE":
+ case "CHECKED":
+ case "SIZE":
+ case "MAXLENGTH":
+ case "SRC":
+ case "ALT":
+ case "USEMAP":
+ case "DISABLED":
+ case "READONLY":
+ case "ACCEPT":
+ case "ACCESSKEY":
+ case "TABINDEX":
+ case "ONFOCUS":
+ case "ONBLUR":
+ case "ONSELECT":
+ case "ONCHANGE":
+ case "ONCLICK":
+ case "ONDBLCLICK":
+ case "ONMOUSEDOWN":
+ case "ONMOUSEUP":
+ case "ONMOUSEOVER":
+ case "ONMOUSEMOVE":
+ case "ONMOUSEOUT":
+ case "ONKEYPRESS":
+ case "ONKEYDOWN":
+ case "ONKEYUP":
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ void AddAttributesForSpan (HtmlTextWriter writer)
+ {
+ 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);
+ }
+ Attributes.AddAttributes (writer);
+ }
#if NET_2_0
protected internal
#else
if (Page != null)
Page.VerifyRenderingInServerForm (this);
- bool need_span = ControlStyleCreated;
+ bool need_span = ControlStyleCreated && !ControlStyle.IsEmpty;
if (need_span)
ControlStyle.AddAttributesToRender (w, this);
if (!Enabled) {
w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
- //need_span = true;
+ need_span = true;
}
string tt = ToolTip;
}
if (Attributes.Count > 0){
+ AddAttributesForSpan (w);
Attributes.AddAttributes (w);
need_span = true;
}
if (align == TextAlign.Right) {
w.AddAttribute (HtmlTextWriterAttribute.Id, ClientID);
w.AddAttribute (HtmlTextWriterAttribute.Type, render_type);
- w.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ w.AddAttribute (HtmlTextWriterAttribute.Name, NameAttribute);
+ InternalAddAttributesToRender (w);
if (Checked)
w.AddAttribute (HtmlTextWriterAttribute.Checked, "checked");
if (AutoPostBack){
w.AddAttribute (HtmlTextWriterAttribute.Onclick,
- Page.ClientScript.GetPostBackClientEvent (this, String.Empty));
+ Page.ClientScript.GetPostBackEventReference (this, String.Empty));
w.AddAttribute ("language", "javascript");
}
w.AddAttribute (HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString (CultureInfo.InvariantCulture));
+ if (common_attrs != null)
+ common_attrs.AddAttributes (w);
w.RenderBeginTag (HtmlTextWriterTag.Input);
w.RenderEndTag ();
string text = Text;
w.RenderEndTag ();
}
- if (!Enabled)
- w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
-
w.AddAttribute (HtmlTextWriterAttribute.Id, ClientID);
w.AddAttribute (HtmlTextWriterAttribute.Type, render_type);
- w.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ w.AddAttribute (HtmlTextWriterAttribute.Name, NameAttribute);
+ InternalAddAttributesToRender (w);
if (Checked)
w.AddAttribute (HtmlTextWriterAttribute.Checked, "checked");
if (AutoPostBack){
w.AddAttribute (HtmlTextWriterAttribute.Onclick,
- Page.ClientScript.GetPostBackClientEvent (this, String.Empty));
+ Page.ClientScript.GetPostBackEventReference (this, String.Empty));
w.AddAttribute ("language", "javascript");
}
w.AddAttribute (HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString (NumberFormatInfo.InvariantInfo));
+ if (common_attrs != null)
+ common_attrs.AddAttributes (w);
w.RenderBeginTag (HtmlTextWriterTag.Input);
w.RenderEndTag ();
}
#endif
bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
+ if (!Enabled)
+ return false;
+
string postedValue = postCollection[postDataKey];
bool postedBool = ((postedValue != null) &&
(postedValue.Length > 0));
internal virtual void InternalAddAttributesToRender (HtmlTextWriter w)
{
- AddAttributesToRender (w);
+ if (!Enabled)
+ w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
}
}
}