How to call JavaScript functions directly in Razor view between HTML tags

I'm iterating a list in my Razor view and I have a date attribute to show in a specific format.

I have used model.MyDatetimeAttr.toString("dd MMM yyy") which is working fine. However it has considerable performance impact (taking too much time to load the page). That's why I want to use a JavaScript function to format my date attribute.

Something like this:

<div> FormatDate( model.MyDatetimeAttr )  </div>. 

FormatDate would be my javascript function. The main question is how to call javaScript function between HTML tags?



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.