Copied to clipboard

Flag this post as spam?

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

  • Justin Spradlin 137 posts 345 karma points
    Oct 04, 2011 @ 08:15
    Justin Spradlin

    Dynamic Properties invalid in Razor


    I have recently upgrade to 4.7.1 and I am pretty sure that this did not happen then. I am trying to render a image tag for a document type "MediaElement" that captures the "Media" and "Thumbnail". Media and Thumbnail are both files picked using the S3 plugin. However I am not getting the correct value back from the dynamicNode in razor. 

    Here are the values that I am seeing in Razor:

        base {System.Dynamic.DynamicObject}: {umbraco.MacroEngines.DynamicXml}
        BaseElement: <value dataTypeId="1135"><![CDATA[ 1 TB HOCM MMODE AV.004.004.jpg]]></value>
        InnerText: " 1 TB HOCM MMODE AV.004.004.jpg"
    {<value dataTypeId="1135"><![CDATA[ 1 TB HOCM M-MODE AV.004.004.jpg]]></value>}
        Alias: "media"
        Value: "<value dataTypeId=\"1135\"><![CDATA[ 1 TB HOCM M-MODE AV.004.004.jpg]]></value>"
        Version: {00000000-0000-0000-0000-000000000000}

    The value of the element.PropertiesAsList[3] (which corresponds to the "Media" node is correct. Notice that the "-" has been removed from the InnerText of the element.Media version (causing invalid data). So when I try to render my node using this bit of razor, it renders an invalid value for the src of my image tag. 


    var mediaUrl = XDocument.Parse(element.Media.ToXml()).Element("value").Value; 
    var thumbnailUrl = XDocument.Parse(element.Thumbnail.ToXml()).Element("value").Value;
    // This doesn't work either
    // var mediaUrl = element.Media.BaseElement.Value;
    // var thumbnailUrl = element.Thumbnail.BaseElement.Value;

    Here is a snipped from the umbraco.config for this node

    <Playlist id="1165" parentID="1147" level="2" writerID="1" creatorID="0" nodeType="1094" template="0" sortOrder="4" createDate="2011-06-18T09:12:09" updateDate="2011-07-18T19:36:54" nodeName="Fig 1 TB" urlName="fig-1-tb" writerName="tommy" creatorName="admin" path="-1,1147,1165" isDoc="">
          <PlaylistElement id="1166" parentID="1165" level="3" writerID="1" creatorID="0" nodeType="1093" template="0" sortOrder="1" createDate="2011-06-18T09:13:21" updateDate="2011-07-18T19:36:54" nodeName="figure 1 TB" urlName="figure-1-tb" writerName="tommy" creatorName="admin" path="-1,1147,1165,1166" isDoc="">
            <title>FIG 1 TB</title>
              <value dataTypeId="1135"><![CDATA[ 1 TB HOCM M-MODE AV.004.004.jpg]]></value>
              <value dataTypeId="1135"><![CDATA[ 1 TB HOCM M-MODE AV.004.004.jpg]]></value>

    Does anyone have any ideas about how I can fix this?

    Thank you,


Please Sign in or register to post replies

Write your reply to: