3

I've media picker in Umbraco 8 and I want to display image in my cshtml page.

@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<body>
    <section class="section">
        <div class="page-header-box">
            <img src="images/Leadership.png" />
        </div>
        <div class="ld-content-box gradientbackground">
            <div class="inner-container">
                <h3 class="ip-title">Leadership</h3>
                <ul class="aboutus-leadership-listing">
                    @foreach (var childPage in Model.Children())
                    {
                        <li data-aos="fade-up">
                            <div class="abll-image-box">
                                @{
                                    var leaderImage = childPage.Value<IPublishedContent>("leaderImage");
                                }

enter image description here

But I am getting error :

The type or namespace name 'IPublishedContent' could not be found (are you missing a using directive or an assembly reference?)

I don't it is issue because of Umbraco V8 or is there anything missing?

UPDATED: enter image description here

Ubiquitous Developers
  • 3,161
  • 4
  • 25
  • 61

3 Answers3

1

IPublishedContent is defined in the Umbraco.Core.Models namespace.

You should have an entry

<add namespace="Umbraco.Core.Models" />

in the system.web.webPages.razor/pages/namespaces section of Views\Web.config.

devio
  • 35,442
  • 6
  • 73
  • 138
0

For namespace and Library

@using Umbraco.Core.Models

For Model

@model Umbraco.Core.Models

For Iterate the list on Razor Page (You Have to use foreach loop for access the list items)

Jin Thakur
  • 2,265
  • 15
  • 12
0

IPublishedContent moved again, now it resides in Umbraco.Core.Models.PublishedContent:

using Umbraco.Core.Models.PublishedContent;
Alexander Gräf
  • 428
  • 3
  • 10