Copied to clipboard

Flag this post as spam?

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


  • Markus 33 posts 58 karma points
    Apr 09, 2011 @ 17:06
    Markus
    0

    Input string was not in a correct format - accessing Multi-Node Tree Picker value with razor

    Hi,

    I'm not sure whether this is linked to the razor support or to the Multi-node tree picker implementation.

    I have a datatype using the multi-node tree picker (MNTP) (configured for Content, minimum node selections is 0, CSV, with XPath expression and filter).

    When I try to get the value and no node has been selected with the MNTP, accessing the value using razor syntax generates an error:

    @Model.myProperty

    I have to use the following workaround:

    @Model.GetProperty("myProperty").Value

    When at least one node is selected, I don't get any errors.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 09, 2011 @ 17:24
    Sebastiaan Janssen
    0

    Part of the dynamic nature of the Razor implementation is that your properties will be evaluated at runtime to see if they can be cast to DynamicXml, lists, etc. When a list is just an empty string (no value), the parser can in no way determine that the values in there were supposed to be a list, so it just returns an empty string.

    So eventually it's up to you to test if the property is empty, if not, do what you want with the list.

  • Markus 33 posts 58 karma points
    Apr 09, 2011 @ 19:07
    Markus
    0

    Actually that's just the point: It doesn't return an empty string - it throws an error. This is different from for example an (empty) numeric property - an empty numeric property returns an empty string.

     

    I checked umbraco.config, the multi-node tree picker looks like this:

    <myProperty><![CDATA[1104]]></myProperty>

    and, when empty, like this:

    <myProperty><![CDATA[]]></myProperty>

    Whereas an empty numeric property does not have the CDATA in it:

    <myNumericProperty />

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 10, 2011 @ 11:23
    Sebastiaan Janssen
    0

    You are correct! I can confirm that this is an issue that will be solved in 4.7.1, the fix has been added to the dev version, I've tested it and this problem is solved. If Codeplex worked, I would've linked to the changeset, but there is a server error at the moment.

    Until 4.7.1 is released your only option is unfortunately to do GetProperty like you did.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 10, 2011 @ 14:40
    Jeroen Breuer
    0

    Currently I've got the same problem. Is there already a nightly build of 4.7.1 where this is fixed?

    Jeroen

  • Barry Fogarty 493 posts 1129 karma points
    Sep 09, 2011 @ 14:12
    Barry Fogarty
    0

    Just to confirm I solved this by grabbing the 4.7.1 nightly of umbraco.MacroEngines.dll from Codeplex.

    Sorry at the moment I cannot locate the link, only 4.7.0 and 5.. it was there a week ago.. :-(

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 09, 2011 @ 15:23
    Jonas Eriksson
    1

    Hi, check out Sebastiaans sample site with lots of Razor code, it has also the new .dll. http://our.umbraco.org/projects/developer-tools/cultiv-razor-examples Other than that you can find the dll in the latest nighlty here http://nightly.umbraco.org/umbraco%204.7.1/4.7.1/ 

Please Sign in or register to post replies

Write your reply to:

Draft