Try our conversational search powered by Generative AI!

Problem with rendering local blocks in MVC EPI 7 Edit MOde, other properties not editable

Vote:
 

I have a block with one property:

public class MyImageBlock : BlockData

    {

        public virtual string Description { get; set; }

    }

    

 

I create a view (even not using Description) for it and I wire it together inside TemplateCoordinator, so it will be using my view when rendering.

 

I have an ArticlePage

public class ArticlePage :

{

        public virtual MyImageBlock DescriptionBlock { get; set; }

        public virtual string MainIntro { get; set; }

}

    

 

In the View for ArticlePage:

 

<h2>@Html.PropertyFor(m=>m.CurrentPage.DescriptionBlock)</h2>

<h2>@Html.PropertyFor(m=>m.CurrentPage.MainIntro)</h2>

    

 

When I am in Edit Mode the block is being rendered properly form MyImageBlock.cshtml but all properties after this one are rendered with EditMode wrappers and cannot be edited using OnPageEdit.

 

Investigation:

Down the road there is a method 'bool CurrentContentContainsProperty<TModel>(HtmlHelper<TModel> html, string propertyName)' which uses

'IContentData GetCurrentData<TModel>(HtmlHelper<TModel> html)'

 

The second method uses Html.ViewContext.RequestContext.RouteData.Values["currentContent"] and from my colleague investigation this has invalid value. It should not be set when use our custom MyImageBlock.cshtml. Actually the stupid workaround is to clear this value after rendering our block.

<h2>@Html.PropertyFor(m=>m.CurrentPage.DescriptionBlock)</h2>

<h2>@Html.PropertyFor(m=>m.CurrentPage.MainIntro)</h2>

@{

    Html.ViewContext.RequestContext.RouteData.Values["currentContent"] = null;

}

 

We don’t want to use Blocks with controller as it decrease performance and I remember from somewhere that EPiServer discourage it.

 

It’s all weird, and we can be wrong, or maybe we miss some small but important thing here. Epi guys, do you have a solution?

 

#73482
Jul 24, 2013 9:21
Vote:
 

Hi,

I have an error like you or similar where we not able to edit the properties on the OnPageEdit, it works fine with the FormsEdit.
I have contacted the support and the only thing I got from those was "this issue for now is not supported. We have sent the feedback to our developers and it will be looked at accordingly."

If you find any solution to this please share it.

#73483
Jul 24, 2013 9:50
Vote:
 

@Magnus thanks for sharing that information. Good to know that "is not supported". 

 

The solution so far in our project is mentioned earlier:

 

@{
    Html.ViewContext.RequestContext.RouteData.Values["currentContent"] = null;
}

    at the end of CustomBlock.cshtml

#73495
Jul 24, 2013 16:48
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.