Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Try this one:
<div @Html.EditAttributes("PageName")>@Html.Display("PageName")</div>
Hi Valdis,
I have tried this and Html.EditAttributes is getting the on-page edit working perfectly, however Html.Display is always rendering nothing. Any idea why?
Paul
Try output just property value: @CurrentPage["PageName"]. Does it renders some content? What data type is for the property that is not rendering?
@CurrentPage["PageName"] gives me raw html like
I am wondering why the .Display would return nothing.
Hi it may be worth taking a look at the following thread as it contains a similar subject:
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=87488
In MVC to be able to get a EPiServer property and make it editable in the on-page-edit I normally use @Html.PropertyFor(m => m.CurrentPage.PageName). But in some cases, eg on the _Root.cshtml I am not sure if a specific property exists, therefor I want to use the code below:
@if (Model.CurrentPage["PageName"] != null) { @Html.PropertyFor(m => m.CurrentPage["PageName"]) }
But when I run this I got this exception:
Unsupported expression. The body of the expression must either be a MemberExpression or a UnaryExpression. On the PropertyFor-row.
Isn't this possible? I am new to MVC so maybe I am doing it totally wrong?