Copied to clipboard

Flag this post as spam?

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


  • Paul Stewart 50 posts 71 karma points
    May 26, 2011 @ 11:50
    Paul Stewart
    0

    Newbie Question: Razor Published Date

    Hey everyone, I just started using razor for the first time yesterday am impressed with how it works. Am more a front end developer (HTML CSS) and learning all about the C# side of development. So my knowledge is pretty slim in regards to doing anything too dynamic and fancy...

    my problem is am creating a news list and i want to show the published date. my News Title and News Summary work in the layout I have.

    @item.newsTitle, @item.newsSummary

    I tried looking about for formatting a published date method, thing closest to it was. 

    @article.ArticleDate.ToString("dd/MM/yyyy")

     And i was recieving a error on the page saying... 

    "Error loading Razor Script News.cshtml
    Cannot invoke a non-delagate type"

    If any one can help that would be great.
    Regards, Paul

  • Richard Boelen 61 posts 153 karma points
    May 27, 2011 @ 21:20
    Richard Boelen
    0

    Not sure what your document type looks like, but it seems you should do some checks on ArticleDate like:

      @if(Model.HasProperty("ArticleDate") &&  Model.ArticleDate is DateTime){
        @Model.ArticleDate.ToString("dd/MM/yyyy")
      }

    Cheers!

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft