Copied to clipboard

Flag this post as spam?

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


  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 26, 2010 @ 14:17
    Kim Andersen
    0

    Get "Text" instead of "Value" from Radiobutton-datatype

    I have made a datatype based on the Radiobutton List. I have to options in it and this works just fine. I have put my new datatype on a field in Umbraco with an alias of: sendMailTo

    But when I need to know what the admin have choosen from sendMailTo I get the actual Value from the datatype - The id of the choosen option. Sure I can check if the value is 45 or 46, but right now I work on a development-environment, and when I'm moving the whole site to a test-environment, I can't be sure that the two id's will be the same except if I move the whole database as well. I could of cource change the id's in my XSLT-code, but then I needed to chage it once more when the site is going to a staging-environment, and then once again when the site goes live.

    So my question is: Can I grab the text from the choosen option, instead of the value?

    By the way - If I used the "Dropdown List" as my base datatype I'll get the text instead of the value, so it's kind of weird, why the same thing is not happening with the Radiobutton List.

    - Thanks

    /Kim A

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jan 26, 2010 @ 14:38
    Thomas Höhler
    2
    umbraco.library:GetPreValueAsString(PREVALUEID) 

    will do the trick...Just put in the prevalue id you got from the radiobutton list.

    hth, Thomas

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 26, 2010 @ 15:10
    Kim Andersen
    0

    Thanks Thomas. This works just like I hoped for :)

    Have a nice day.

     

    /Kim A

  • karen 186 posts 461 karma points
    Jan 27, 2010 @ 19:39
    karen
    0

    Can you give an example of this?

    I have my datatype on RadioButton list with two values, Open/Closed.

    So when I put in my template: <umbraco:Item runat='server' field='cutOpen' />   it displays 11 or 12

    So I am not sure how to change that to use umbraco.library:GetPreValueAsString ?

    Thanks

  • karen 186 posts 461 karma points
    Jan 27, 2010 @ 19:47
    karen
    0

    This is what I tried

    <umbraco:Item runat="server" field="cutOpen" xslt="umbraco.library:GetPreValueAsString({0})/data[@alias='cutOpen']" />

    But getting nothing back?

    Thanks

     

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jan 27, 2010 @ 22:13
    Thomas Höhler
    1

    As the name says: it returns a string so this should work:

    <umbraco:Item runat="server" field="cutOpen" xslt="umbraco.library:GetPreValueAsString({0})" />

    hth, Thomas

  • karen 186 posts 461 karma points
    Jan 27, 2010 @ 22:23
    karen
    0

    Excellent!  Thank you!

  • Christian Rieß 24 posts 46 karma points
    May 14, 2012 @ 16:06
    Christian Rieß
    1

    This also works in Razor:

    @umbraco.library.GetPreValueAsString(PREVALUEID); 
  • R2-D2 11 posts 31 karma points
    Aug 06, 2012 @ 11:15
    R2-D2
    0

    i found this that worked for me:

    @umbraco.library.GetPreValueAsString(int.Parse(node.property))

  • Vance 5 posts 63 karma points
    Jan 21, 2014 @ 00:47
    Vance
    0

    i also tried and it was working for me.

    Thanks !!

Please Sign in or register to post replies

Write your reply to:

Draft