Copied to clipboard

Flag this post as spam?

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


  • Phil Crowe 192 posts 256 karma points
    Oct 28, 2010 @ 15:28
    Phil Crowe
    0

    Converting label or textstring to int

    Ive created a new label in a document called 'worthATry'. This label stores an integer. when i try calling this property into a variable in c# i get "Object reference not set to an instance of an object" error, but when i try a different property like a tickbox (returning 1 or 0) it works perfectly. is there a reason i cannot convert a textsring or label to an int?

     int INT3 = Convert.ToInt32(n.GetProperty("worthATry").Value); // doesnt work

     int INT3 = Convert.ToInt32(n.GetProperty("tickbox ").Value); //does work

     i have definitely used the correct alias for the property.

  • Phil Crowe 192 posts 256 karma points
    Oct 28, 2010 @ 15:40
    Phil Crowe
    0

    Turns out the property wasnt getting read at all, umbraco was messed up. after i deleted the umbraco.config and republished the site it was fine! 

Please Sign in or register to post replies

Write your reply to:

Draft