Reputation: 27996
I have created a helper method in view like this:
@helper DisputeOpenedDays(DateTime createdDate)
{
TimeSpan difference = DateTime.Now.Subtract(createdDate);
string.Format("0", difference.Days);
}
and when I use it in view like this
@DisputeOpenedDays(myobj.CreatedAt)
It doesnt print any thing
Upvotes: 0
Views: 134
Reputation: 10443
@helper DisputeOpenedDays(DateTime createdDate)
{
TimeSpan difference = DateTime.Now.Subtract(createdDate);
@string.Format("{0}", difference.Days);
}
ASP.NET MVC 3 and the @helper syntax within Razor - ScottGu's Blog
Upvotes: 0
Reputation: 31416
Try:
string.Format("{0}", difference.Days);
The curly braces are missing.
Upvotes: 3