diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2002-06-09 23:28:27 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2002-06-09 23:28:27 +0400 |
commit | 343b0a1d2becfb71b94442f806dcfa0c90eb869d (patch) | |
tree | 848796e806c108224a4b18532960079bc68aa710 /mcs/class/System.Web | |
parent | 856ab374d01fa690af72a9c3e0920ec198c434fc (diff) |
2002-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* System.Web.UI/ControlCollection.cs:
(AddAt): if index is -1 behave as a plain Add.
* System.Web.UI.HtmlControls/HtmlSelect.cs:
(RenderAttributes): new -> override and fixes stack overflow.
(RenderChildren): only 1 option can be selected at any given time
except when Multiple property is true.
(Multiple): the attribute value is either "true" or "false", not
"multiple".
* System.Web.UI.HtmlControls/HtmlTable.cs:
(Add):
(AddAt): allow HtmlTableRow as children, not HtmlTableCell.
* System.Web.UI.HtmlControls/HtmlTableCell.cs:
(RenderEndTag): new -> override.
* System.Web.UI.HtmlControls/HtmlTableRow.cs:
(RenderChildren): fixed another stack overflow.
(RenderEndTag): new -> override.
* System.Web.UI.HtmlControls/HtmlTextArea.cs:
(RenderAttributes): new -> override.
svn path=/trunk/mcs/; revision=5193
Diffstat (limited to 'mcs/class/System.Web')
8 files changed, 55 insertions, 17 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog index 78e8746570d..f3e75d021ae 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog @@ -1,3 +1,27 @@ +2002-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * HtmlSelect.cs: + (RenderAttributes): new -> override and fixes stack overflow. + (RenderChildren): only 1 option can be selected at any given time + except when Multiple property is true. + (Multiple): the attribute value is either "true" or "false", not + "multiple". + + * HtmlTable.cs: + (Add): + (AddAt): allow HtmlTableRow as children, not HtmlTableCell. + + * HtmlTableCell.cs: + (RenderEndTag): new -> override. + + * HtmlTableRow.cs: + (RenderChildren): fixed another stack overflow. + (RenderEndTag): new -> override. + + * HtmlTextArea.cs: + (RenderAttributes): new -> override. + + 2002-06-07 Gonzalo Paniagua Javier <gonzalo@ximian.com> * HtmlInputHidden.cs: fixed constructor. diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs index 1e57a367cce..4fd11f8f6fb 100755 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs @@ -101,13 +101,13 @@ namespace System.Web.UI.HtmlControls{ handler.Invoke(this,e);
}
- protected new void RenderAttributes(HtmlTextWriter writer){
+ protected override void RenderAttributes(HtmlTextWriter writer){
writer.WriteAttribute("name", Name);
Attributes.Remove("name");
Attributes.Remove("DataValueField");
Attributes.Remove("DataTextField");
Attributes.Remove("DataMember");
- RenderAttributes(writer);
+ base.RenderAttributes(writer);
}
protected override void RenderChildren(HtmlTextWriter writer){
@@ -117,12 +117,19 @@ namespace System.Web.UI.HtmlControls{ writer.Indent = writer.Indent + 1;
if (Items.Count >= 0){
// display all options, and set the selected option
+ bool rendered_selected = false;
foreach (ListItem option in Items){
//write begin tag with attributes
writer.WriteBeginTag("option");
- if (option.Selected == true){
+ if (!rendered_selected && option.Selected){
writer.WriteAttribute("selected","selected");
+ if (!Multiple)
+ rendered_selected = true;
}
+ else if (option.Selected){
+ option.Selected = false;
+ }
+
writer.WriteAttribute("value",option.Value,true);
option.Attributes.Remove("text");
option.Attributes.Remove("value");
@@ -306,12 +313,11 @@ namespace System.Web.UI.HtmlControls{ public bool Multiple{
get{
string attr = Attributes["multiple"];
- if (attr != null) return attr.Equals("multiple");
+ if (attr != null) return (0 == String.Compare (attr, "true", true));
return false;
}
set{
- if (value == true) Attributes["multiple"] = "multiple";
- else Attributes["multiple"] = null;
+ Attributes["multiple"] = value.ToString ();
}
}
@@ -327,7 +333,7 @@ namespace System.Web.UI.HtmlControls{ public virtual int SelectedIndex {
get{
- for (int i=0; i<=Items.Count; i++){
+ for (int i=0; i<Items.Count; i++){
if (Items[i].Selected == true) return i;
}
if (Size<=1 && !Multiple){
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs index 800b64a0bc8..6a70743c2d0 100755 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs @@ -149,20 +149,20 @@ namespace System.Web.UI.HtmlControls{ internal HtmlTableRowControlCollection(Control owner): base(owner){}
public override void Add(Control child){
- if ((child as HtmlTableCell) != null){
+ if ((child as HtmlTableRow) != null){
base.Add(child);
}
else{
- throw new ArgumentException("HtmlTableRow cannot have children of type" + child.GetType().Name);
+ throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
}
}
public override void AddAt(int index, Control child){
- if ((child as HtmlTableCell) != null){
+ if ((child as HtmlTableRow) != null){
base.AddAt(index,child);
}
else{
- throw new ArgumentException("HtmlTableRow cannot have children of type" + child.GetType().Name);
+ throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
}
}
} // end of HtmlTableRowControlCollection
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs index 6815acf909a..38d77f4f471 100755 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs @@ -14,7 +14,7 @@ namespace System.Web.UI.HtmlControls{ public HtmlTableCell(string tagName): base(tagName){}
- protected new void RenderEndTag(HtmlTextWriter writer){
+ protected override void RenderEndTag(HtmlTextWriter writer){
base.RenderEndTag(writer);
writer.WriteLine();
}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs index 378e149d835..f08f657ee0c 100755 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs @@ -19,11 +19,11 @@ namespace System.Web.UI.HtmlControls{ protected override void RenderChildren(HtmlTextWriter writer){
writer.WriteLine();
writer.Indent = writer.Indent + 1;
- this.RenderChildren(writer);
+ base.RenderChildren(writer);
writer.Indent = writer.Indent - 1;
}
- protected new void RenderEndTag(HtmlTextWriter writer){
+ protected override void RenderEndTag(HtmlTextWriter writer){
base.RenderEndTag(writer);
writer.WriteLine();
}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs index f5652958241..9d32d73af0e 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs @@ -90,7 +90,7 @@ namespace System.Web.UI.HtmlControls{ return false;
}
- protected new void RenderAttributes(HtmlTextWriter writer){
+ protected override void RenderAttributes(HtmlTextWriter writer){
writer.WriteAttribute("name", Name);
Attributes.Remove("name");
base.RenderAttributes(writer);
diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 0e6018a25e3..2c52948b7e7 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,8 @@ +2002-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * ControlCollection.cs: + (AddAt): if index is -1 behave as a plain Add. + 2002-06-06 Gonzalo Paniagua Javier <gonzalo@ximian.com> * Page.cs: for each child control to render, assign Control.Page. diff --git a/mcs/class/System.Web/System.Web.UI/ControlCollection.cs b/mcs/class/System.Web/System.Web.UI/ControlCollection.cs index ce03e58b1b2..c24e2fecf6b 100755 --- a/mcs/class/System.Web/System.Web.UI/ControlCollection.cs +++ b/mcs/class/System.Web/System.Web.UI/ControlCollection.cs @@ -63,13 +63,16 @@ namespace System.Web.UI { if (child == null) // maybe we should check for ! (child is Control)? throw new ArgumentNullException (); - if ((index < 0) || (index > Count)) + if ((index < -1) || (index > Count)) throw new ArgumentOutOfRangeException (); if (IsReadOnly) throw new HttpException (); - list [index] = child; + if (index == -1) + Add (child); + else + list [index] = child; } public virtual void Clear () |