我有一把umbraco剃刀脚本是相当复杂的,我想在它的一些点来呈现一个宏它。
这就是所谓SuggestionBox宏实际上是一个用户控件(.ascx)和传统,这是在模板上使用引用
<umbraco:macro Alias="SuggestionBox" language="cshtml" runat="server"></umbraco:macro>
但现在我需要从剃刀脚本,而不是所以我试图把它;
@Html.Raw(umbraco.library.RenderMacroContent("SuggestionBox", Model.Id))
以及:
@RenderPage("SuggestionBox")
至今没有运气,因为我敢肯定,我错误地使用这些。
我读的地方,如果页面被包裹在一个母版可能是不可行的。
它的工作原理,如果我把它添加到我喜欢将传统的模板:
<umbraco:macro Alias="EventsRenderer" language="cshtml" runat="server"></umbraco:macro>
<div class="talkingPointPanel">
<h3><umbraco:Item field="talkingPoinstSuggestionText" runat="server"></umbraco:Item></h3>
<umbraco:macro Alias="SuggestionBox" language="cshtml" runat="server"></umbraco:macro>
</div>
凡EventsRenderer将呈现最好应包含SuggestionBox的页面。
运用
@Html.Raw(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"SuggestionBox\" />", Model.Id))
给我这个错误:
<!-- Error generating macroContent: 'System.Web.HttpException (0x80004005): HtmlForm cannot render without a reference to the Page instance. Make sure your form has been added to the control tree.
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at umbraco.presentation.templateControls.Macro.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at umbraco.library.RenderMacroContent(String Text, Int32 PageId)' -->
有任何想法吗?