Merging Template Areas onto MVC Views

If you are using the Hosted Application, the entire template for the page will be rendered in the browser, however if you are using ASP.NET MVC your controller action has probably returned a view page from the MVC Project, this view may contain an MVC Master page, and may contain layout that is not controlled by the CMS. To get your template from the CMS page that is mapped to the controller action you can use a web control:

On the CMS Template you define Placeholder Content:

    <placeholder type="content" name="fragment1">This is my CMS controlled template fragment that I want to appear on my MVC View</placeholder>

On the MVC View, you use the TemplatePlaceholder web control:

    <mwcms:TemplatePlaceholder runat="server" PlaceholderName="fragment1" />

Any standard HTML is rendered into the view, along with the custom HTML that will be generated by any of the template language the CMS uses.

NOTE You need to ensure you have registered the web controls correctly in your application, see ASP.NET MVC Configuration

Last edited Jun 10, 2011 at 12:28 PM by methodworx, version 3


No comments yet.