Author: gonzalo
Date: 2005-03-09 18:21:06 -0500 (Wed, 09 Mar 2005)
New Revision: 41623

Modified:
   branches/mono-1-0/mcs/class/System.Web/System.Web.UI/ChangeLog
   branches/mono-1-0/mcs/class/System.Web/System.Web.UI/Control.cs
Log:
2005-03-09 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * Control.cs: in FindControl, throw if there's more than one control
        with the same ID. Fixes bug #73479.
 


Modified: branches/mono-1-0/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- branches/mono-1-0/mcs/class/System.Web/System.Web.UI/ChangeLog      
2005-03-09 23:19:52 UTC (rev 41622)
+++ branches/mono-1-0/mcs/class/System.Web/System.Web.UI/ChangeLog      
2005-03-09 23:21:06 UTC (rev 41623)
@@ -1,3 +1,8 @@
+2005-03-09 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * Control.cs: in FindControl, throw if there's more than one control
+       with the same ID. Fixes bug #73479.
+ 
 2004-12-14 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * ControlCollection.cs: fix off-by-one and store a null at the end to

Modified: branches/mono-1-0/mcs/class/System.Web/System.Web.UI/Control.cs
===================================================================
--- branches/mono-1-0/mcs/class/System.Web/System.Web.UI/Control.cs     
2005-03-09 23:19:52 UTC (rev 41622)
+++ branches/mono-1-0/mcs/class/System.Web/System.Web.UI/Control.cs     
2005-03-09 23:21:06 UTC (rev 41623)
@@ -492,26 +492,39 @@
                 {
                        return FindControl (id, 0);
                 }
-
-               Control LookForControlByName (string id)
-               {
+
+               Control LookForControlByName (string id)
+               {
                        if (!HasControls ())
                                return null;
-
+
+                       Control result = null;
                        foreach (Control c in Controls) {
-                               if (String.Compare (id, c._userId, true) == 0)
-                                       return c;
-
-                               if ((c.stateMask & IS_NAMING_CONTAINER) == 0 && 
c.HasControls ()) {
-                                       Control child = c.LookForControlByName 
(id);
-                                       if (child != null)
-                                               return child;
-                               }
-                       }
-
-                       return null;
-               }
-               
+                               if (String.Compare (id, c._userId, true) == 0) {
+                                       if (result != null && result != c) {
+                                               Console.WriteLine 
(c.GetHashCode ());
+                                               Console.WriteLine 
(result.GetHashCode ());
+                                               throw new HttpException ("1 
Found more than one control with ID '" + id + "'");
+                                       }
+
+                                       result = c;
+                                       continue;
+                               }
+
+                               if ((c.stateMask & IS_NAMING_CONTAINER) == 0 && 
c.HasControls ()) {
+                                       Control child = c.LookForControlByName 
(id);
+                                       if (child != null) {
+                                               if (result != null && result != 
child)
+                                                       throw new HttpException 
("2 Found more than one control with ID '" + id + "'");
+
+                                               result = child;
+                                       }
+                               }
+                       }
+
+                       return result;
+               }
+
                 protected virtual Control FindControl (string id, int 
pathOffset)
                 {
                        EnsureChildControls ();

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

Reply via email to