Copied to clipboard

Flag this post as spam?

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


  • Andrew Munro 78 posts 161 karma points
    Apr 25, 2013 @ 01:03
    Andrew Munro
    0

    Empty property string returns umbraco.MacroEngines.DynamicXml when using DynamicNode

    Hi Guys - I've been having this problem a lot latley and I'm not sure the best way to work around it. Whenever I try to access an empty string property, rather than returning an empty string it returns, umbraco.MacroEngines.DynamicXml.

    Do you guys know a good way to get umbraco to stop returning this in the event of empty strings or do you know a good way to check for this rather than doing a typeof (DynamicXml). 

    Thanks for your help.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 25, 2013 @ 05:02
    Fuji Kusaka
    100

    Hi Andrew,

    Have you tried checking if the property Alias is empty or not before displaying the value?

    if(Model.HasValue("alias")){
    //do something
    }

    or

    if(!String.IsNullOrEmpty(Model.Alias)){
    //do something
    }
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Apr 25, 2013 @ 15:31
    Jeavon Leopold
    0

    Hi Andrew, what version of Umbraco are you using? Also are you having this problem with content properties or media properties (or both)?

    There is a existing issue you can vote for relating to empty properties on media items http://issues.umbraco.org/issue/U4-579

    A workaround is to use something like:

    @using umbraco.MacroEngines
    @{
    if (Model.simple.GetType() == typeof(DynamicXml)){
    @Html.Raw(Model.simple.ToXml().ToString())
    } else {
    @Html.Raw(Model.simple.ToString())
    }
    }

    Thanks,

    Jeavon

  • Andrew Munro 78 posts 161 karma points
    Apr 25, 2013 @ 16:58
    Andrew Munro
    0

    Hi Guys, I'm using 6.0.1. For the time being I think I will just do a Model.HasValue. I might just create a small helper method to do this step for me but this will work for now. 

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft