Moves all FindCOntrolRecursive calls to an extension method
This commit is contained in:
@@ -132,7 +132,7 @@ namespace umbraco.editorControls
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytesControl = FindControlRecursive<noEdit>(Page, "prop_" + prop);
|
||||
var bytesControl = Page.FindControlRecursive<noEdit>("prop_" + prop);
|
||||
if (bytesControl != null)
|
||||
{
|
||||
bytesControl.RefreshLabel(string.Empty);
|
||||
@@ -184,7 +184,7 @@ namespace umbraco.editorControls
|
||||
|
||||
private static void UpdateLabelValue(string propAlias, string controlId, Page controlPage, Content content)
|
||||
{
|
||||
var extensionControl = FindControlRecursive<noEdit>(controlPage, controlId);
|
||||
var extensionControl = controlPage.FindControlRecursive<noEdit>(controlId);
|
||||
if (extensionControl != null)
|
||||
{
|
||||
if (content.getProperty(propAlias) != null && content.getProperty(propAlias).Value != null)
|
||||
@@ -261,41 +261,7 @@ namespace umbraco.editorControls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively finds a control with the specified identifier.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">
|
||||
/// The type of control to be found.
|
||||
/// </typeparam>
|
||||
/// <param name="parent">
|
||||
/// The parent control from which the search will start.
|
||||
/// </param>
|
||||
/// <param name="id">
|
||||
/// The identifier of the control to be found.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The control with the specified identifier, otherwise <see langword="null"/> if the control
|
||||
/// is not found.
|
||||
/// </returns>
|
||||
private static T FindControlRecursive<T>(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<T>(control, id);
|
||||
if (foundControl != null)
|
||||
{
|
||||
return foundControl;
|
||||
}
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Render this control to the output parameter specified.
|
||||
/// </summary>
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.IO;
|
||||
|
||||
using Umbraco.Core;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace umbraco.editorControls.userControlGrapper
|
||||
foreach (KeyValuePair<string, DataEditorSettingType> k in dtSettings)
|
||||
{
|
||||
var result = k.Value.Validate();
|
||||
Label lbl = FindControlRecursive<Label>(_phSettings, "lbl" + k.Key);
|
||||
Label lbl = _phSettings.FindControlRecursive<Label>("lbl" + k.Key);
|
||||
if(result == null && lbl != null)
|
||||
{
|
||||
if(lbl != null)
|
||||
@@ -320,25 +320,6 @@ namespace umbraco.editorControls.userControlGrapper
|
||||
}
|
||||
}
|
||||
|
||||
private static T FindControlRecursive<T>(Control parent, string id) where T : Control
|
||||
{
|
||||
if ((parent is T) && (parent.ID == id))
|
||||
{
|
||||
return (T)parent;
|
||||
}
|
||||
|
||||
foreach (Control control in parent.Controls)
|
||||
{
|
||||
T foundControl = FindControlRecursive<T>(control, id);
|
||||
if (foundControl != null)
|
||||
{
|
||||
return foundControl;
|
||||
}
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user