Author: gonzalo
Date: 2005-03-09 18:19:52 -0500 (Wed, 09 Mar 2005)
New Revision: 41622
Modified:
trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
trunk/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: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2005-03-09 23:18:18 UTC
(rev 41621)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2005-03-09 23:19:52 UTC
(rev 41622)
@@ -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.
+
2005-03-04 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* Page.cs: Load control state before loading view state, and the
Modified: trunk/mcs/class/System.Web/System.Web.UI/Control.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Control.cs 2005-03-09 23:18:18 UTC
(rev 41621)
+++ trunk/mcs/class/System.Web/System.Web.UI/Control.cs 2005-03-09 23:19:52 UTC
(rev 41622)
@@ -510,26 +510,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