Try our conversational search powered by Generative AI!

Get the HTML for a Block or Page?


Is there a simple way to generate and get the HTML for a Block or a Page? Let´s say I know the ID for a Block and I want the generated HTML as it would be if the block was generated in a ContentArea as it normally would. Blocks and partial page.


Feb 18, 2013 15:58

The short answer is no.

In EPiServer 7 data and templates have been separeted. That is the data does not control how it gets rendered. How it works is that when a  content is to be rendered (page, block etc.) a request is made to TemplateResolver to decide which template to use to render the item. The resolver will choose the most appropriate template depending on the context (e.g WebForms or MVC, active DisplayChannels, specified tags). 

So what you would need to do is to call TemplateResolver to resolve a template. That will give you back a reference to either a UserControl, WebControl, MVC partial Controller or MVC partial view. Then you would need to render that control in some way (like e.g. host it on a temporay page, make a request for the page and extract the generated HTML).

Feb 19, 2013 7:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.