Skip to content

Commit

Permalink
backport from head
Browse files Browse the repository at this point in the history
svn path=/branches/mono-1-1-13/mcs/; revision=59823
  • Loading branch information
gonzalop committed Apr 24, 2006
1 parent 2dbfa82 commit ffa2b97
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 19 deletions.
9 changes: 7 additions & 2 deletions mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
@@ -1,15 +1,20 @@
2006-04-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>

* CheckBox.cs: certain attributes have to be rendered in the input tag,
not the <span>. Fixes bug #71251.

2006-04-06 Konstantin Triger <kostat@mainsoft.com> 2006-04-06 Konstantin Triger <kostat@mainsoft.com>


* BaseDataList.cs: Fix searching control by DataSourceID. * BaseDataList.cs: Fix searching control by DataSourceID.
* DataList.cs: Enable binding using DataSourceID for NET_2_0. * DataList.cs: Enable binding using DataSourceID for NET_2_0.




2006-03-29 Robert Jordan <robertj@gmx.net> 2006-03-29 Robert Jordan <robertj@gmx.net>

* DataGrid.cs: if custom paging is enabled the persisted item count * DataGrid.cs: if custom paging is enabled the persisted item count
must be the count of the rendered items, otherwise paging from the must be the count of the rendered items, otherwise paging from the
last to a previous page won't work correctly. Fixes bug #77556. last to a previous page won't work correctly. Fixes bug #77556.

2006-03-29 Vladimir Krasnov <vladimirk@mainsoft.com> 2006-03-29 Vladimir Krasnov <vladimirk@mainsoft.com>


* RepeatInfo.cs: fixed RenderBeginTag to set enabled value of table * RepeatInfo.cs: fixed RenderBeginTag to set enabled value of table
Expand Down
83 changes: 66 additions & 17 deletions mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
Expand Up @@ -26,6 +26,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //


using System.Collections;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
Expand All @@ -50,6 +51,7 @@ public class CheckBox : WebControl, IPostBackDataHandler
#endif #endif
{ {
string render_type; string render_type;
AttributeCollection common_attrs;


#if NET_2_0 #if NET_2_0
AttributeCollection inputAttributes; AttributeCollection inputAttributes;
Expand Down Expand Up @@ -180,15 +182,7 @@ public virtual string Text
[WebCategory ("Appearance")] [WebCategory ("Appearance")]
public virtual TextAlign TextAlign public virtual TextAlign TextAlign
{ {
get { get { return (TextAlign) ViewState.GetInt ("TextAlign", (int)TextAlign.Right); }
object o = ViewState["TextAlign"];

if (o == null) {
return (TextAlign.Right);
} else {
return ((TextAlign)o);
}
}
set { set {
if (value != TextAlign.Left && if (value != TextAlign.Left &&
value != TextAlign.Right) { value != TextAlign.Right) {
Expand All @@ -204,7 +198,7 @@ public virtual TextAlign TextAlign
[DefaultValue ("")] [DefaultValue ("")]
[WebSysDescription ("")] [WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")] [WebCategoryAttribute ("Behavior")]
public string ValidationGroup public virtual string ValidationGroup
{ {
get { return ViewState.GetString ("ValidationGroup", String.Empty); } get { return ViewState.GetString ("ValidationGroup", String.Empty); }
set { ViewState["ValidationGroup"] = value; } set { ViewState["ValidationGroup"] = value; }
Expand Down Expand Up @@ -310,6 +304,57 @@ override void OnPreRender (EventArgs e)
} }
} }


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 #if NET_2_0
protected internal protected internal
#else #else
Expand All @@ -320,13 +365,13 @@ override void Render (HtmlTextWriter w)
if (Page != null) if (Page != null)
Page.VerifyRenderingInServerForm (this); Page.VerifyRenderingInServerForm (this);


bool need_span = ControlStyleCreated; bool need_span = ControlStyleCreated && !ControlStyle.IsEmpty;
if (need_span) if (need_span)
ControlStyle.AddAttributesToRender (w, this); ControlStyle.AddAttributesToRender (w, this);


if (!Enabled) { if (!Enabled) {
w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled"); w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
//need_span = true; need_span = true;
} }


string tt = ToolTip; string tt = ToolTip;
Expand All @@ -336,6 +381,7 @@ override void Render (HtmlTextWriter w)
} }


if (Attributes.Count > 0){ if (Attributes.Count > 0){
AddAttributesForSpan (w);
Attributes.AddAttributes (w); Attributes.AddAttributes (w);
need_span = true; need_span = true;
} }
Expand All @@ -354,7 +400,7 @@ override void Render (HtmlTextWriter w)


if (AutoPostBack){ if (AutoPostBack){
w.AddAttribute (HtmlTextWriterAttribute.Onclick, w.AddAttribute (HtmlTextWriterAttribute.Onclick,
Page.ClientScript.GetPostBackClientEvent (this, String.Empty)); Page.ClientScript.GetPostBackEventReference (this, String.Empty));
w.AddAttribute ("language", "javascript"); w.AddAttribute ("language", "javascript");
} }


Expand All @@ -365,6 +411,8 @@ override void Render (HtmlTextWriter w)
w.AddAttribute (HtmlTextWriterAttribute.Tabindex, w.AddAttribute (HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString (CultureInfo.InvariantCulture)); TabIndex.ToString (CultureInfo.InvariantCulture));


if (common_attrs != null)
common_attrs.AddAttributes (w);
w.RenderBeginTag (HtmlTextWriterTag.Input); w.RenderBeginTag (HtmlTextWriterTag.Input);
w.RenderEndTag (); w.RenderEndTag ();
string text = Text; string text = Text;
Expand All @@ -391,9 +439,6 @@ override void Render (HtmlTextWriter w)
w.RenderEndTag (); w.RenderEndTag ();
} }


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

w.AddAttribute (HtmlTextWriterAttribute.Id, ClientID); w.AddAttribute (HtmlTextWriterAttribute.Id, ClientID);
w.AddAttribute (HtmlTextWriterAttribute.Type, render_type); w.AddAttribute (HtmlTextWriterAttribute.Type, render_type);
w.AddAttribute (HtmlTextWriterAttribute.Name, NameAttribute); w.AddAttribute (HtmlTextWriterAttribute.Name, NameAttribute);
Expand All @@ -403,7 +448,7 @@ override void Render (HtmlTextWriter w)


if (AutoPostBack){ if (AutoPostBack){
w.AddAttribute (HtmlTextWriterAttribute.Onclick, w.AddAttribute (HtmlTextWriterAttribute.Onclick,
Page.ClientScript.GetPostBackClientEvent (this, String.Empty)); Page.ClientScript.GetPostBackEventReference (this, String.Empty));
w.AddAttribute ("language", "javascript"); w.AddAttribute ("language", "javascript");
} }


Expand All @@ -414,6 +459,8 @@ override void Render (HtmlTextWriter w)
w.AddAttribute (HtmlTextWriterAttribute.Tabindex, w.AddAttribute (HtmlTextWriterAttribute.Tabindex,
TabIndex.ToString (NumberFormatInfo.InvariantInfo)); TabIndex.ToString (NumberFormatInfo.InvariantInfo));


if (common_attrs != null)
common_attrs.AddAttributes (w);
w.RenderBeginTag (HtmlTextWriterTag.Input); w.RenderBeginTag (HtmlTextWriterTag.Input);
w.RenderEndTag (); w.RenderEndTag ();
} }
Expand Down Expand Up @@ -470,6 +517,8 @@ protected override void AddAttributesToRender (HtmlTextWriter writer)


internal virtual void InternalAddAttributesToRender (HtmlTextWriter w) internal virtual void InternalAddAttributesToRender (HtmlTextWriter w)
{ {
if (!Enabled)
w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
} }
} }
} }

0 comments on commit ffa2b97

Please sign in to comment.