Copied to clipboard

Flag this post as spam?

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


  • Jon 92 posts 166 karma points
    Mar 26, 2021 @ 16:33
    Jon
    0

    Alternative to GetPreValueAsString in Umbraaco 8

    Im trying to convert this code from umbraco 7 into Umbraco 8.

     var returnVal = "";
                var text = umbraco.library.GetPreValueAsString(LinksSubheading);
                switch (text)
                {
                    case "List Whole Alphabet":
                        returnVal =  "AZ";
                        break;
                    case "List Children Only":
                        returnVal =  "CAT";
                        break;
                    case "Hide":
                        returnVal =  "NONE";
                        break;
                }
                return returnVal;
    

    I cant find an alternative - any ideas?

  • Marc Goodson 2126 posts 14217 karma points MVP 8x c-trib
    Mar 29, 2021 @ 11:06
    Marc Goodson
    0

    Hi Jon

    I'd need to double check, but this was the case in V7, as the ids of the dropdown options were stored for the property, and you needed Umbraco to lookup the label for the ID, whichis what GetPreValueAsString used to do...

    I think now instead of storing the ID, it's the label text that is stored?

    In which case... what is the raw value of LinksSubheading?

    does it contain your label text?

    eg do you need to call anything at all in V8!

    regards

    marc

  • Youngsan 7 posts 77 karma points
    Apr 07, 2022 @ 03:36
    Youngsan
    0

    According to the article, GetPreValueAsString replaced with Model.Value.

    Upgrading the Wanderly platform from Umbraco 7 to 8

    Pre values are gone in Umbraco 8 Model.Value<string>(“propertyAlias”) replaces umbraco.GetPreValueAsString(Model.Content.GetPropertyValue<int>(“propertyAlias”))
    
Please Sign in or register to post replies

Write your reply to:

Draft