From fa54d0a1e8ed3808d41735dfb82ef4769fbf2cbf Mon Sep 17 00:00:00 2001 From: starfighter83 Date: Thu, 6 Jan 2011 09:04:41 -0100 Subject: [PATCH] Fixes 29799: Macro Container: ordering macros throws exception on some nodes --- .../editorControls/macrocontainer/Editor.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/editorControls/macrocontainer/Editor.cs b/components/editorControls/macrocontainer/Editor.cs index e0a37fd339..5f9c5ae066 100644 --- a/components/editorControls/macrocontainer/Editor.cs +++ b/components/editorControls/macrocontainer/Editor.cs @@ -257,18 +257,24 @@ namespace umbraco.editorControls.macrocontainer { string number = temp.Substring(temp.LastIndexOf('=') + 1); - MacroEditor current = ((MacroEditor)this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + number)); - if (current.Visible) - value += current.MacroTag; + if (this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + number) != null) + { + MacroEditor current = ((MacroEditor)this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + number)); + if (current.Visible) + value += current.MacroTag; + } } } else { for (int i = 0; i < _maxNumber; i++) { - MacroEditor current = ((MacroEditor)this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + i.ToString())); - if (current.Visible) - value += current.MacroTag; + if (this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + i.ToString()) != null) + { + MacroEditor current = ((MacroEditor)this.ContentTemplateContainer.FindControl(ID + "macroeditor_" + i.ToString())); + if (current.Visible) + value += current.MacroTag; + } } } _data.Value = value;