Copied to clipboard

Flag this post as spam?

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


  • lonehorseend 24 posts 71 karma points
    Jul 18, 2014 @ 01:50
    lonehorseend
    0

    Upload Datatype - How do I do this is in Umbraco 7? - Same code works perfectly fine in 6

    @if (Model.Content.GetPropertyValue("courseLogo").ToString().Length > 0)
    { img src="@Model.Content.GetPropertyValue }

    (plus the proper <> around the img tag) used to work in Version 6 just fine.  Now, in Umbraco 7, it doesn't. It's returns empty and gives the server fits.

    It's a Upload Datatype with the name of courseLogo. When I look at the documentation for the Upload DataType - ,http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/Property-Editors/Built-in-Property-Editors/Upload it references "umbracoFile" as the name I'm supposed to be using. But how can I do that when I have 2 upload fields on the same page. They both can't be named umbracoFile. 

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 18, 2014 @ 08:21
    Dennis Aaen
    2

    Hi lonehorseend,

    To me it looks like that you are trying to print the image from the Upload Datatype, but only if the field is not empty.

    You can do it this way:

    @{      
       if (Model.Content.HasValue("courseLogo")){
           <img src="@Model.Content.GetPropertyValue("courseLogo") /> 
       } 
    }
    

    The HasValue checks that the field is not empty.

    Hope this helps, if I have misunderstood your question, don't hesitate to write again,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft