I am having real trouble getting a usercontrol macro to work whilst placed via the RTE and rendered using umbraco.library:RenderMacroContent. The problem only seems to be when I include a ValidationSummary control within the usercontrol. Here is the error I get on render:
<!-- Error generating macroContent: 'System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.UI.WebControls.ValidationSummary.GetErrorMessages(Boolean& inError)
at System.Web.UI.WebControls.ValidationSummary.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at umbraco.presentation.templateControls.Macro.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at umbraco.library.RenderMacroContent(String Text, Int32 PageId)' -->
I have no problem including this macro via a template :S
Unfortunately I don't think RenderMacroContent works well with usercontrols that contain any server-side forms. You'd have to output the content in the template for it to work properly -- or use a Razor macro or other solution.
.Net Usercontrols with ValidationSummary
Hi,
I am having real trouble getting a usercontrol macro to work whilst placed via the RTE and rendered using umbraco.library:RenderMacroContent. The problem only seems to be when I include a ValidationSummary control within the usercontrol. Here is the error I get on render:
<!-- Error generating macroContent: 'System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.UI.WebControls.ValidationSummary.GetErrorMessages(Boolean& inError)
at System.Web.UI.WebControls.ValidationSummary.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at umbraco.presentation.templateControls.Macro.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at umbraco.library.RenderMacroContent(String Text, Int32 PageId)' -->
I have no problem including this macro via a template :S
Any help is much appreciated.
Scott
I should also mention I am on v4.9.
Cheers
S
Hi Scott,
Unfortunately I don't think RenderMacroContent works well with usercontrols that contain any server-side forms. You'd have to output the content in the template for it to work properly -- or use a Razor macro or other solution.
http://our.umbraco.org/forum/developers/xslt/2872-RenderMacroContent-problem
Sorry there's not better news!
Tom
is working on a reply...