diff --git a/src/Umbraco.Core/ControlExtensions.cs b/src/Umbraco.Core/ControlExtensions.cs new file mode 100644 index 0000000000..391c69159f --- /dev/null +++ b/src/Umbraco.Core/ControlExtensions.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web.UI; + +namespace Umbraco.Core +{ + internal static class ControlExtensions + { + /// + /// Recursively finds a control with the specified identifier. + /// + /// + /// The type of control to be found. + /// + /// + /// The parent control from which the search will start. + /// + /// + /// The identifier of the control to be found. + /// + /// + /// The control with the specified identifier, otherwise if the control + /// is not found. + /// + public static T FindControlRecursive(this Control parent, string id) where T : Control + { + if ((parent is T) && (parent.ID == id)) + { + return (T)parent; + } + + foreach (Control control in parent.Controls) + { + var foundControl = FindControlRecursive(control, id); + if (foundControl != null) + { + return foundControl; + } + } + return default(T); + } + + } +} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index aa55c55f5a..98a2aab8b9 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -148,6 +148,7 @@ + diff --git a/src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs b/src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs index ac3f9409fb..82a0385c32 100644 --- a/src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs +++ b/src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs @@ -1,7 +1,7 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; - +using Umbraco.Core; using umbraco.interfaces; using umbraco.BusinessLogic; using umbraco.DataLayer; @@ -175,7 +175,7 @@ namespace umbraco.cms.businesslogic.datatype foreach (KeyValuePair k in dtSettings) { var result = k.Value.Validate(); - Label lbl = FindControlRecursive