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).
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.
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.
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
}
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
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!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.