Copied to clipboard

Flag this post as spam?

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


  • Mark Johnston 59 posts 111 karma points
    Apr 17, 2011 @ 19:32
    Mark Johnston
    0

    Using a textstring data type fails in Razor for me

    Hi, 

    I am using a textstring data type in my site to denote jQuery version which would then be written into the textstring data type in the form of "1.5.2", no quotes and it the current version of jQuery I am wanting to support.

    When I go to use Razor to retreive it using "@Model.AncestorOrSelf(1).jQueryVersion;" it is being returned as a datetime format for some reason which means it renders to the page as "1/05/2002 12:00:00 AM;" 

    Am I doing something wrong or is this in fact a bug?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 17, 2011 @ 19:35
    Sebastiaan Janssen
    0

    This is a result of the Umbraco Razor implementation trying to ducktype your string. You can force it to be read a string like so:

    @Model.AncestorOrSelf(1).GetProperty("jQueryVersion").Value;
  • Mark Johnston 59 posts 111 karma points
    Apr 25, 2011 @ 01:46
    Mark Johnston
    0

    While this does work it is not as I would expect as I can get back values for other datatypes the method I used but seems inconsistent that because the value I had is a number with fullstops between it that it converts to a date.

Please Sign in or register to post replies

Write your reply to:

Draft