Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Goldsmith 14 posts 33 karma points
    Aug 02, 2019 @ 10:00
    Simon Goldsmith
    0

    Model always null when trying to show DocumentTypes.field values

    Firstly, I am new to Umbraco.

    I have a partialview called Intro.cshtml and I want to use the field "introText" in it. The field "introText" is a textbox field and forms part of a DocumentType called "Intro Controls", and it is assigned to all my documenttypes.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
    <div id="fh5co-intro-section">
        <div class="container">
            <div class="row">
                <div class="col-md-8 col-md-offset-2 text-center">
                    <h2>@Model.Value("introText", fallback: Fallback.ToAncestors)</h2>
                </div>
            </div>
        </div>
    </div>
    

    In v7 I could just do @Currentpage.introText, and it would work, but in v8 this does not work for me.The above code also errors though as @model is null.

    What am I missing?

    THanks Simon

  • Simon Goldsmith 14 posts 33 karma points
    Aug 09, 2019 @ 14:21
    Simon Goldsmith
    0

    @Umbraco.AssignedContentItem.GetProperty("introText").Value()

Please Sign in or register to post replies

Write your reply to:

Draft