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
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
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
is working on a reply...