Author: igorz
Date: 2006-12-11 03:12:16 -0500 (Mon, 11 Dec 2006)
New Revision: 69300

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/RadioButtonTest.cs
Log:
2006-12-11 Igor Zelmanovich <[EMAIL PROTECTED]>

        * RadioButton.cs: fixed:
        When GroupName is not defined UniqueID is used instead for name 
attribute.
        CheckedChanged is raised only when control is checked.


Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-12-11 07:56:38 UTC (rev 69299)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-12-11 08:12:16 UTC (rev 69300)
@@ -1,3 +1,10 @@
+2006-12-11 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+       * RadioButton.cs: fixed:
+       When GroupName is not defined UniqueID is used instead for name 
attribute.
+       CheckedChanged is raised only when control is checked.
+       
+
 2006-12-10 Igor Zelmanovich <[EMAIL PROTECTED]>
 
        * Menu.cs: fixed: rendering.

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs 
2006-12-11 07:56:38 UTC (rev 69299)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs 
2006-12-11 08:12:16 UTC (rev 69300)
@@ -68,6 +68,8 @@
                        get {
                                string unique = UniqueID;
                                string gn = GroupName;
+                               if (gn.Length == 0)
+                                       return unique;
                                int colon = -1;
                                if (unique != null)
                                        colon = unique.IndexOf (':');
@@ -111,19 +113,12 @@
 #endif
                bool LoadPostData (string postDataKey, NameValueCollection 
postCollection) 
                {
-                       bool old_checked = Checked;
-                       
-                       if (postCollection[NameAttribute] == postDataKey) {
-                               Checked = true;
-                       } else {
-                               Checked = false;
-                       }
+                       bool checkedOnClient = postCollection[NameAttribute] == 
postDataKey;
+                       if (Checked == checkedOnClient)
+                               return false;
 
-                       if (old_checked != Checked) {
-                               return (true);
-                       } else {
-                               return (false);
-                       }
+                       Checked = checkedOnClient;
+                       return checkedOnClient;                 
                }
 
 #if NET_2_0

Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-12-11 07:56:38 UTC (rev 69299)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-12-11 08:12:16 UTC (rev 69300)
@@ -1,3 +1,7 @@
+2006-12-11  Igor Zelmanovich   <[EMAIL PROTECTED]>
+
+       * RadioButtonTest.cs: added tests.
+
 2006-12-10  Igor Zelmanovich   <[EMAIL PROTECTED]>
 
        * MasterPageTest.cs: added NotWorking attribute.

Modified: 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/RadioButtonTest.cs
===================================================================
--- 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/RadioButtonTest.cs    
    2006-12-11 07:56:38 UTC (rev 69299)
+++ 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/RadioButtonTest.cs    
    2006-12-11 08:12:16 UTC (rev 69300)
@@ -187,7 +187,21 @@
                        Assert.IsTrue (t2.IndexOf ("name=\"mono\"") != -1, 
"#02");
                }
 
+               [Test]
+               public void NameAttr2 () {
+                       TestRadioButton b1 = new TestRadioButton ();
+                       b1.ID = "monoId";
+                       Page p = new Page ();
 #if NET_2_0
+                       p.EnableEventValidation = false;
+#endif
+                       p.ID = "MyPage";
+                       p.Controls.Add (b1);
+                       string t1 = b1.Render ();
+                       Assert.IsTrue (t1.IndexOf ("name=\"monoId\"") != -1, 
"#01");
+               }
+
+#if NET_2_0
                [Test]
                public void RaisePostDataChangedEvent ()
                {
@@ -205,7 +219,6 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                [Category ("NunitWeb")]
                public void RaisePostDataChangedEvent_PostBack ()
                {
@@ -219,24 +232,40 @@
                        fr.Controls["__EVENTARGUMENT"].Value = "";
                        fr.Controls["RadioButton1"].Value = "RadioButton1";
                        t.Request = fr;
-                       t.Run ();
+                       event_CheckedChanged2_flag = false;
+                       html = t.Run ();
                        if (t.UserData == null)
                                Assert.Fail ("RaisePostDataChangedEvent 
Failed#1");
                        Assert.AreEqual ("CheckedChanged", (string) t.UserData, 
"RaisePostDataChangedEvent Failed#2");
+                       Assert.IsFalse (event_CheckedChanged2_flag, 
"RaisePostDataChangedEvent Failed#3");
                }
 
                public static void RaisePostDataChangedEvent_Init (Page p)
                {
                        TestRadioButton b = new TestRadioButton ();
                        b.ID = "RadioButton1";
+                       b.GroupName = "RadioButton1";
                        b.CheckedChanged+=new 
EventHandler(event_CheckedChanged);
                        p.Form.Controls.Add (b);
+                       
+                       TestRadioButton b2 = new TestRadioButton ();
+                       b2.ID = "RadioButton2";
+                       b2.GroupName = "RadioButton1";
+                       b2.CheckedChanged += new EventHandler 
(event_CheckedChanged2);
+                       p.Form.Controls.Add (b2);
+                       if (!p.IsPostBack)
+                               b2.Checked = true;
                }
 
                public static void event_CheckedChanged (object sender, 
EventArgs e)
                {
                        WebTest.CurrentTest.UserData = "CheckedChanged";
                }
+               static bool event_CheckedChanged2_flag;
+               public static void event_CheckedChanged2 (object sender, 
EventArgs e)
+               {
+                       event_CheckedChanged2_flag = true;
+               }
 
                #region help_class
                class Poker : RadioButton
@@ -278,7 +307,6 @@
                #endregion
 
                [Test]
-               [Category ("NotWorking")]
                [Category ("NunitWeb")]
                public void LoadPostData ()  //Just flow and not implementation 
detail
                {
@@ -287,8 +315,10 @@
                        FormRequest fr = new FormRequest (t.Response, "form1");
                        fr.Controls.Add ("__EVENTTARGET");
                        fr.Controls.Add ("__EVENTARGUMENT");
-                       fr.Controls["__EVENTTARGET"].Value = "RadioButton1";
+                       fr.Controls.Add ("RadioButton1");
+                       fr.Controls["__EVENTTARGET"].Value = "__Page";
                        fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls ["RadioButton1"].Value = "RadioButton1";
                        t.Request = fr;
                        t.Run ();
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to