Copied to clipboard

Flag this post as spam?

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


  • gilad 185 posts 425 karma points
    Apr 23, 2012 @ 17:17
    gilad
    0

    usercontrol datatype save without CDATA + render issue

    Hello everyone.

    I am using umbraco 4.7.1 , make some umbraco usercontrol wrapper datatype.

    in my user control i have that code for saving the prtoperty..

     public object value
        {
            get
            {  
                return SomeHiddenFieldId.Value;
            }
            set
            {
                umbracoValue = value.ToString();
            }
        }

    in umbraco.config the property saved like this :

     <alias><![CDATA[1266,1227]]></alias>

    There is a way to avoid this CDATA?

    i want it will be like this :

     <alias>1266,1227</alias>

    Another issue - when i try to use this propery in macro for some reason if there is only two items

    ( the property is holding some id's ) it is look like this :

    TWO ITEMS :

    in umbraco.config :  <alias><![CDATA[1266,1227]]></alias>

    in macro : <p>@item.alias.ToString()</>

    result : 12661227   ( without the comma )

    THREE ITEMS :

    in umbraco.config :  <alias><![CDATA[1266,1227,1244]]></alias>

    in macro : <p>@item.alias.ToString()</>

    result : 1266,1227,1244   ( good! )

    Thanks in advance.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 23, 2012 @ 17:45
    Tom Fulton
    0

    Hi,

    Sorry I'm not 100% sure about your first question, but your second issue sounds like Razor is doing some strange casting.  It's possible that may be fixed in 4.7.1.1.

    One solution/workaround would be to use Model.GetProperty("alias").Value instead of Model.alias - the first one will always return a string, the second one it tries to cast which is probably where your issue is happening.

    Another solution I was going to suggest is that you can write a RazorDataTypeModel with your DataType, then you can have Model.alias automatically return something like a List<int> or even List<DynamicNode>...but I think you won't be able to do this with the usercontrolwrapper since it works off the datatype's GUID (which will be the same for all usercontrol datatypes).

    HTH,
    Tom 

  • gilad 185 posts 425 karma points
    Apr 24, 2012 @ 09:26
    gilad
    0

    Hi Tom.

    Thanks for the quick response.

    the first solution ( GetProperty.("alias") ) sloved the issue.

    Fabulous. Thanks!

  • gilad 185 posts 425 karma points
    Apr 29, 2012 @ 08:56
    gilad
    0

    Anyone about the CDATA issue??

Please Sign in or register to post replies

Write your reply to:

Draft