How can I render the result of Html.Action() from within a custom helper?
Due to an implementation detail, I have what would be a partial view that needs to be a full-fledged view "rendered" using <%= Html.Action(Model.ViewerToRender) %>
. It works fine in my dev spike where I can put that line directly on the page, but in the production code it must be in a View开发者_如何学CPage helper method that returns a void. Given the htmlString
variable in the following code, how can I render it to the page from within this helper?
public static void RenderDocumentViewer(this ViewPage<DocumentViewModel> page)
{
if(!page.Model.UseRenderPartial)
{
var htmlString = page.Html.Action(page.Model.ViewerToRender);
// The following line is what I don't know how to do:
page.RenderHtml(htmlString);
return;
}
page.Html.RenderPartial(page.Model.ViewerToRender);
}
Try
page.Response.Write(htmlString);
精彩评论