Copied to clipboard

Flag this post as spam?

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

  • steschu 66 posts 381 karma points
    Jul 17, 2019 @ 15:09

    property textstring numeric characters automatically convert to real number


    I have a textstring property where I put some version numbers in it (e.g. "1.0"). When I query the model I noticed that somehow automatically the string is regarded as a number, because the value appears as "1" (without the . and 0) on the page. In the model cs file I can see that the property is generated as type of object. This may be the reason. But how could this be solved?

    Kind regards, Stephan

  • David Challener 80 posts 341 karma points c-trib
    Jul 17, 2019 @ 15:35
    David Challener

    Hi Stephan,

    This probably depends on how you're retrieving the property. Are you using models builder or using GetPropertyValue() ?

    You can specify a type with GetPropertyValue eg


    If using models builder that's a bit strange, but would take a look at the type it has created and change the model (depending what mode you're running) - need more info from you here.

    HTH, David

  • steschu 66 posts 381 karma points
    Jul 17, 2019 @ 20:34

    Hi David,

    Forgot to mention that the textstring comes from a custom property editor. I forgot to implement a Property Value Converter. That was the reason. Now everything works fine. Here's the documentation ( and my implementation below:

    using System;
    using Umbraco.Core;
    using Umbraco.Core.PropertyEditors;
    using Umbraco.Core.Models.PublishedContent;
    using Umbraco.Web;
    namespace Plugins.MyTextbox
        [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
        public class MyTextboxPropertyConverter : IPropertyValueConverter
            public object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
                return Convert.ToString(source);
            public object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
                return source;
            public object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview)
                return source.ToString();
            public bool IsConverter(PublishedPropertyType propertyType)
                return propertyType.PropertyEditorAlias.Equals("MyCustom.MyTextbox");
Please Sign in or register to post replies

Write your reply to: