Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

@Html.EditAttributes doesn't auto make UI updated?


Hi all,

I got a block called Callout, it's not used as a regular block. It's used as a composite property (AvailableInEditMode=false) on another block. It has some properties and one of them is "CalloutContent"

In my view I display only CalloutContent but i using Html.EditAttributes so it's easy for update all other properties of block Callout


m.CurrentBlock.Callout)> @Html.PropertyFor(m => m.CurrentBlock.Callout.CalloutContent)

I go to edit mode and click the callout content area to edit my properties, but after leave the edit property form, my view show "Callout can't be displayed"

I have thought that the view should be updated and i can see my new CalloutContent

Anyone know what is wrong?

May 31, 2018 9:37

On page editing of properties in MVC works so that when a property value has been updated a request is made to PropertyRender Controller (you can see this request from browser if you open up developer tools). That controller will then basically render a view which does @Html.PropertyFor(theProperty). So in your case will it call the PropertyRender Controller that it should render property 'Callout' (since that is what you specify in EditAttributes). So you need to have a partial template for Callout (that basically could call render CalloutContent) that can be used during editing.

May 31, 2018 12:07

This is not how on-page-edit works. I would recommend you to change your code to something like this:

@Html.PropertyFor(m => m.CurrentBlock.Callout)

Then create a view called Callout in /views/shared/blocks/Callout.cshtml. And in this view you put:

@model Callout

   @Model.CalloutContent<br />

If you already have a view for the block, then you can use a tag and create a view for that tag instead:

@Html.PropertyFor(m => m.CurrentBlock.Callout, new { Tag = "MyTag" })

And name the view MyTag instead /views/shared/displaytemplates/MyTag.cshtml

Edited, May 31, 2018 12:53
<p>It works, that's great. Thank you much :)</p>
Jun 01, 2018 4:57

Lucy, Can you please clarify if Johan B's solution works, or Johan P's?  or both?

Jun 01, 2018 18:03
* 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.