Try our conversational search powered by Generative AI!

Render blocks with PropertyFor


I have a custom block with two properties - an image url and an alternative text

        GUID = "387A029C-F193-403C-89C9-375A2A6BF028",
        AvailableInEditMode = false,
        DisplayName = "Image" 

    public class ImageBlock : EPiServer.Core.BlockData
            Name = "Image Url",
            Description = "",
            GroupName = SystemTabNames.Content,  
            Order = 10)]
        public virtual Url ImageUrl { get; set; }

            Name = "Alternative text",
            GroupName = SystemTabNames.Content,
            Order = 20)]
        public virtual string AlternativeText { get; set; }


I have created a partial view in shared directory /shared/ImageBlock/index.cshtml as 

@model ImageBlock
<img src="@Model.ImageUrl" />


So I am hoping when I call something like 



My partial view should get called, but the partial view never gets called.

- TestProperty is a property of type ImageBlock


Can any body please help me


Aug 02, 2013 17:57

Does it say it can't find a renderer for the property? If I recall correctly, the correct path to the ImageBlock partial should be "Views/Shared/ImageBlock.cshtml", unless you are pushing the block through a controller.

Aug 02, 2013 18:58

Hi, Tahir,

I have not placed my ImageBlock (that I am using as local block and rendering with PropertyFor) inside Views/Shared/ImageBlock.cshtml.

Instead, I have placed it inside Views/Shared/DisplayTemplates/ImageBlock.cshtml

Aug 05, 2013 14:59

i'm facing a similar dilema to Tahir, I have tried putting into DisplayTemplates although still get the message their is no render for this block. 

For now I am using seperate controllers although dont think this is the tidiest thing to do. 

Aug 06, 2013 9:58
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.