Copied to clipboard

Flag this post as spam?

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


  • Andrew Moscardino 6 posts 96 karma points
    Nov 17, 2017 @ 16:39
    Andrew Moscardino
    0

    Color Picker returning numbers

    I'm using the Color Picker all over the site I am working on. Recently, I updated from 7.3.1 to 7.7.5 and some of the colors stopped working. Specifically, some colors seem to be interpreted and returned as numbers in scientific notation.

    For example, 949e16 is one of the colors. When I try to retrieve it using someContent.GetPropertyValue<string>("color") I get 9.49E+18.

    I've tried re-adding that prevalue to the data type. I've tried republishing all the content that uses the color picker. I've changed the values to other colors and they work fine, but any hex code that resembles a number is converted when I retrieve the value.

    Any help is appreciated.

  • Sven Geusens 169 posts 881 karma points c-trib
    Nov 20, 2017 @ 11:50
    Sven Geusens
    0

    Hey Andrew

    Just tried, but can't seem to reproduce it.

    As a last resort, could you check if the "Property editor alias" of your datatype is set to "Umbraco.ColorPickerAlias"

  • Andrew Moscardino 6 posts 96 karma points
    Nov 20, 2017 @ 13:33
    Andrew Moscardino
    0

    It is Umbraco.ColorPickerAlias.

  • Andrew Moscardino 6 posts 96 karma points
    Nov 20, 2017 @ 15:43
    Andrew Moscardino
    100

    I believe I figured out a workaround. I created a custom property value converter that does essentially nothing but is for the color picker.

    using Umbraco.Core.Models.PublishedContent;
    using Umbraco.Core.PropertyEditors;
    
    namespace MySite.Web
    {
        [PropertyValueType(typeof(string))]
        public class ColorPickerPropertyValueConverter : IPropertyValueConverter
        {
            public bool IsConverter(PublishedPropertyType propertyType)
            {
                return propertyType.PropertyEditorAlias == "Umbraco.ColorPickerAlias";
            }
    
            public object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
            {
                return (source ?? string.Empty).ToString();
            }
    
            public object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
            {
                return (source ?? string.Empty).ToString();
            }
    
            public object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview)
            {
                return (source ?? string.Empty).ToString();
            }
        }
    }
    

    For now, this works, but I'm open to better solutions.

  • Sven Geusens 169 posts 881 karma points c-trib
    Nov 20, 2017 @ 16:05
    Sven Geusens
    0

    Did you have CorePropertyValueConverters installed before the upgrade? If so, uninstall it

  • Andrew Moscardino 6 posts 96 karma points
    Nov 20, 2017 @ 16:09
    Andrew Moscardino
    0

    No. Never installed it.

  • Sven Geusens 169 posts 881 karma points c-trib
    Nov 22, 2017 @ 09:28
    Sven Geusens
    0

    Last thing I can imagine that has gone wrong is some of the dll files were not copied properly during the upgrade.

    If you installed trough nuget, copy all files from packages\UmbracoCms.Core.7.7.5\lib\net45 into your bin folder

    else copy from the zip you got

Please Sign in or register to post replies

Write your reply to:

Draft