Merge pull request #2084 from joelmartinez/mdoc-deletetestfix
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / RadioButtonList.cs
index cf612cac9a14b0f8f70f261fca91309b2d2338f7..86ba336d3e46b68c4e92e591d59fe0b24ee1d4be 100644 (file)
@@ -41,14 +41,9 @@ namespace System.Web.UI.WebControls {
        [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [ValidationProperty ("SelectedItem")]
-#if NET_2_0
        [SupportsEventValidation]
-#endif
-       public class RadioButtonList : ListControl, IRepeatInfoUser,
-               INamingContainer, IPostBackDataHandler {
-#if !NET_2_0
-               bool need_raise;
-#endif
+       public class RadioButtonList : ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler
+       {
                short tabIndex = 0;
 
                public RadioButtonList ()
@@ -56,9 +51,6 @@ namespace System.Web.UI.WebControls {
 
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (-1)]
                [WebSysDescription ("")]
                [WebCategory ("Layout")]
@@ -75,9 +67,6 @@ namespace System.Web.UI.WebControls {
                        }
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (-1)]
                [WebSysDescription ("")]
                [WebCategory ("Layout")]
@@ -94,9 +83,6 @@ namespace System.Web.UI.WebControls {
                        }
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (0)]
                [WebSysDescription ("")]
                [WebCategory ("Layout")]
@@ -113,9 +99,6 @@ namespace System.Web.UI.WebControls {
                        }
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (RepeatDirection.Vertical)]
                [WebSysDescription ("")]
                [WebCategory ("Layout")]
@@ -132,9 +115,6 @@ namespace System.Web.UI.WebControls {
                        }
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (RepeatLayout.Table)]
                [WebSysDescription ("")]
                [WebCategory ("Layout")]
@@ -144,16 +124,15 @@ namespace System.Web.UI.WebControls {
                        }
 
                        set {
-                               if (value != RepeatLayout.Flow && value != RepeatLayout.Table)
+                               bool outOfRange;
+                               outOfRange = value < RepeatLayout.Table || value > RepeatLayout.OrderedList;
+                               if (outOfRange)
                                        throw new ArgumentOutOfRangeException ("The radio buttons layout is not one of the RepeatLayout values.");
 
                                ViewState ["RepeatLayout"] = value;
                        }
                }
 
-#if ONLY_1_1
-               [Bindable (true)]
-#endif         
                [DefaultValue (TextAlign.Right)]
                [WebSysDescription ("")]
                [WebCategory ("Appearance")]
@@ -172,54 +151,36 @@ namespace System.Web.UI.WebControls {
 
                // Interface properties
 
-#if NET_2_0
-               [MonoTODO]
-               protected virtual bool HasFooter
-               {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               protected virtual bool HasFooter {
+                       get { return false; }
                }
 
-               [MonoTODO]
-               protected virtual bool HasHeader 
-               {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               protected virtual bool HasHeader {
+                       get { return false; }
                }
 
-               [MonoTODO]
-               protected virtual bool HasSeparators
-               {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               protected virtual bool HasSeparators {
+                       get { return false; }
                }
-               
-               [MonoTODO]
-               protected virtual int RepeatedItemCount
-               {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+
+               protected virtual int RepeatedItemCount {
+                       get { return Items.Count; }
                }
-#endif
                
                bool IRepeatInfoUser.HasFooter {
-                       get { return false; }
+                       get { return HasFooter; }
                }
 
                bool IRepeatInfoUser.HasHeader {
-                       get { return false; }
+                       get { return HasHeader; }
                }
 
                bool IRepeatInfoUser.HasSeparators {
-                       get { return false; }
+                       get { return HasSeparators; }
                }
 
                int IRepeatInfoUser.RepeatedItemCount {
-                       get { return Items.Count; }
+                       get { return RepeatedItemCount; }
                }
 
                protected override Style CreateControlStyle ()
@@ -227,49 +188,47 @@ namespace System.Web.UI.WebControls {
                        return new TableStyle (ViewState);
                }
 
-#if NET_2_0
-               [MonoTODO]
+               // MSDN: Searches the current naming container for a server control 
+               // with the specified ID and path offset. The FindControl method 
+               // always returns the RadioButtonList object. 
                protected override Control FindControl (string id, int pathOffset)
                {
-                       throw new NotImplementedException ();
+                       return this;
                }
-#endif
 
-#if NET_2_0
-               protected virtual
-#endif
-               Style GetItemStyle (ListItemType itemType, int repeatIndex)
+               protected virtual Style GetItemStyle (ListItemType itemType, int repeatIndex)
                {
                        return null;
                }
 
-#if NET_2_0
-               protected virtual
-#endif
-               void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
+               protected virtual void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
                {
+                       ListItem item = Items [repeatIndex];
+
                        RadioButton radio = new RadioButton ();
-                       radio.Text = Items [repeatIndex].Text;
+                       radio.Text = item.Text;
                        radio.ID = ClientID + "_"  + repeatIndex;
                        radio.TextAlign = TextAlign;
                        radio.GroupName = UniqueID;
                        radio.Page = Page;
-                       radio.Checked = Items [repeatIndex].Selected;
-                       radio.ValueAttribute = Items [repeatIndex].Value;
+                       radio.Checked = item.Selected;
+                       radio.ValueAttribute = item.Value;
                        radio.AutoPostBack = AutoPostBack;
-                       radio.Enabled = Enabled;
+                       radio.Enabled = IsEnabled;
                        radio.TabIndex = tabIndex;
-#if NET_2_0
                        radio.ValidationGroup = ValidationGroup;
                        radio.CausesValidation = CausesValidation;
-#endif
+                       if (radio.HasAttributes)
+                               radio.Attributes.Clear ();
+                       if (item.HasAttributes)
+                               radio.Attributes.CopyFrom (item.Attributes);
+
                        radio.RenderControl (writer);
                }
-#if NET_2_0
-               protected virtual
-#endif
-               bool LoadPostData (string postDataKey, NameValueCollection postCollection)
+
+               protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
                {
+                       EnsureDataBound ();
                        string val = postCollection [postDataKey];
                        ListItemCollection items = Items;
                        int end = items.Count;
@@ -281,34 +240,21 @@ namespace System.Web.UI.WebControls {
 
                                if (i != selected) {
                                        SelectedIndex = i;
-#if NET_2_0
                                        return true;
-#else
-                                       need_raise = true;
-#endif
                                }
-#if !NET_2_0
-                               return true;
-#endif
                        }
 
                        return false;
                }
 
-#if NET_2_0
-               protected virtual
-#endif
-               void RaisePostDataChangedEvent ()
+               protected virtual void RaisePostDataChangedEvent ()
                {
-#if NET_2_0
-                       if (CausesValidation)
-                               Page.Validate (ValidationGroup);
-#endif
-
-#if !NET_2_0
-                       if (need_raise)
-#endif
-                               OnSelectedIndexChanged (EventArgs.Empty);
+                       ValidateEvent (UniqueID, String.Empty);
+                       Page page = Page;
+                       if (CausesValidation && page != null)
+                               page.Validate (ValidationGroup);
+
+                       OnSelectedIndexChanged (EventArgs.Empty);
                }
 
                bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
@@ -331,17 +277,15 @@ namespace System.Web.UI.WebControls {
                        RenderItem (itemType, repeatIndex, repeatInfo, writer);
                }
 
-#if NET_2_0
-               protected internal
-#else          
-               protected
-#endif         
-               override void Render (HtmlTextWriter writer)
+               protected internal override void Render (HtmlTextWriter writer)
                {
-#if NET_2_0
+                       Page page = Page;
+                       if (page != null)
+                               page.ClientScript.RegisterForEventValidation (UniqueID);
+
                        if (Items.Count == 0)
                                return;
-#endif
+
                        RepeatInfo repeat = new RepeatInfo ();
                        repeat.RepeatColumns = RepeatColumns;
                        repeat.RepeatDirection = RepeatDirection;
@@ -359,3 +303,6 @@ namespace System.Web.UI.WebControls {
 }
 
 
+
+
+