Try our conversational search powered by Generative AI!

Problem using DOPE for Block on Layout page in MVC


I used this tutorial to switch between SiteLogotypeBlock2 rendering in WebForms and MVC:

When I use @Html.PropertyFor(m => m.SiteLogotype) on start page, for example, I get the correct rendering and DOPE support.

However, I do not want to add logo to each page, I want to add it to "master" _layout page. Here, I cannot use  @Html.PropertyFor(m => m.SiteLogotype), so I am using @{ Html.RenderAction("Logo", "SiteLogotypeBlock2"); } instead.

This is how my controller looks like (I have the edit hint):

public ActionResult Logo()
if (StartPage != null)
var viewModel = new SiteLogotypeBlock2ViewModel();

AutoMapper.Mapper.Map(StartPage.SiteLogotype, viewModel);

var editingHints = ViewData.GetEditHints<SiteLogotypeBlock2ViewModel, SiteLogotypeBlock2>();
editingHints.AddConnection(x => x.LogotypeUrl, x => x.SiteLogotypeUrl);

return PartialView("SiteLogotypeBlock2", viewModel);

return null;


Earlier, I had a method with currentBlock as a parameter, but it is always null, so instead I need to read it from start page.

public override ActionResult Index(SiteLogotypeBlock2 currentBlock)

// currentBlock always null!


Is this fixable or should we have an implementation that is based on the fact that Blocks on Layout pages are not supported?

Dec 13, 2012 15:42


If you are not rendering your content using PropertyFor you need to add some html yourself that informs the UI that this area should be on page editable for a specific property. There is an extension method called EditAttributes that can help with that. In you case it could look something like this: 

<div @Html.EditAttributes(m => m.SiteLogotypeUrl)>
  @{ Html.RenderAction("Logo", "SiteLogotypeBlock2"); } 


Per Gunsarfs

Dec 13, 2012 16:13

I do not specify a Model on Layout page, so I get the following error, when I inlcude EditAttributes:

An expression tree may not contain a dynamic operation

This error is solved by specifying @model (, but I can't specify @model PROJECT.Web.Models.Pages.StartPage, as it wouldn't work on pages other than StartPage.

Dec 13, 2012 16:25

Ok, then you can should be able the overload of EditAttributes that is not strongly typed instead.


Dec 13, 2012 16:34

Unfortunately, this doesn't help either, I do not get the DOPE support. I have added your suggestion.

<div class="span2" @Html.EditAttributes("SiteLogotypeUrl")>

@{ Html.RenderAction("Logo", "SiteLogotypeBlock2"); }



Dec 17, 2012 18:00

Hmm, and is the property on your content type called "SiteLogotypeUrl"? Looking at your first code sample it looks like the property on your StartPage is called "SiteLogotype".

What html is rendered for the div when the page is openend in the edit view?

Dec 18, 2012 10:05

Yes, that's the trick!! Thx a lot  for your time, so sorry about such a mistake!

Dec 18, 2012 13:54
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.