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
Original file line number Diff line number Diff line change
@@ -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>

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


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

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

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

* 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// 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;
Expand All @@ -50,6 +51,7 @@ public class CheckBox : WebControl, IPostBackDataHandler
#endif
{
string render_type;
AttributeCollection common_attrs;

#if NET_2_0
AttributeCollection inputAttributes;
Expand Down Expand Up @@ -180,15 +182,7 @@ public virtual string Text
[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) {
Expand All @@ -204,7 +198,7 @@ public virtual TextAlign TextAlign
[DefaultValue ("")]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public string ValidationGroup
public virtual string ValidationGroup
{
get { return ViewState.GetString ("ValidationGroup", String.Empty); }
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
protected internal
#else
Expand All @@ -320,13 +365,13 @@ override void Render (HtmlTextWriter w)
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;
Expand All @@ -336,6 +381,7 @@ override void Render (HtmlTextWriter w)
}

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

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

Expand All @@ -365,6 +411,8 @@ override void Render (HtmlTextWriter w)
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;
Expand All @@ -391,9 +439,6 @@ override void Render (HtmlTextWriter w)
w.RenderEndTag ();
}

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

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

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

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

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

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

0 comments on commit ffa2b97

Please sign in to comment.