Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

AdditionalViewData and EditAttributes rendering in Edit-mode

Vote:
 

I have problems rendering a property in Edit mode when the property ha changed.

The view Image.cshml renders the image with the CssClass. This is a simplified example.

Image.cshtml

@model EPiServer.Url
<img src="@Model.Path" class="@ViewData["CssClass"]">

 

In the page view

<figure @Html.EditAttributes(x => x.CurrentPage.Image)>
    @Html.DisplayFor(x => x.CurrentPage.Image, new { CssClass = "img-responsive"})
    @if (!string.IsNullOrEmpty(@Model.CurrentPage.Image.GetFileSummary().Description)) {
        <figcaption>@Model.CurrentPage.Image.GetFileSummary().Description</figcaption>
    }
</figure>

When editing the Image property (which is of type Url) the new image is viewed, but the all additional view data dissapear.

If I change the code to this the view data don't dissapear, but the caption gets outside the property which is not what I want. Does anyone has a solution to this problem which come up many times when developing with EPiServer 7.

<figure>
    @Html.PropertyFor(x => x.CurrentPage.Image, new { CssClass = "img-responsive"})
    @if (!string.IsNullOrEmpty(@Model.CurrentPage.Image.GetFileSummary().Description)) {
        <figcaption>@Model.CurrentPage.Image.GetFileSummary().Description</figcaption>
    }
</figure>
#77240
Nov 13, 2013 14:48
Vote:
 
#77558
Nov 21, 2013 10:32
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.