In previous article I started preparing custom iframe view. For the news page I displayed teaser text. In this post I will describe how to render current page in ContentArea.
see also - current page in ContentArea

In the template I used property control <EPiServer:Property PropertyName=”MainContentArea” runat=”server”/>. The control will render MainContentArea property value for currently edited page. I wanted to render currently edited page as a MainContentArea item.

To make it work, in code-behind OnInit mehtod I created a new instance of News Page.

Then added CurrentPage to MainContentArea:

And then replaced current page with fake news page:

But when I run the application, the item was not renderred.
see also - missing content
After debugging the code it turned out that page was not in edit mode and that’s why item was filtered out from collection of ContentArea items.
see also - PageEditing

The only way to change editing mode (which I found) was to set contextmode variable in DataTokens.

When run the code once again, rendering start working.

see also - render content area item

Below is the full code-behind source code.

and markup

In next post I will show how to add fake items to ContentArea.