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;