c# - How to display a TimeSpan in MVC Razor -
so have duration in seconds of video , display duration in razor.
currently using
@timespan.fromseconds(item.duration).tostring() however rest of code using uses
@html.displayfor(modelitem => item.description) is there way duration (currently int) display timespan? using @html.displayfor syntax. item.duration pulling form entity framework model held int in database.
you can extend model class using partial class definition.
public partial class my_class_that_has_been_created_by_ef { public string timespan { { return timespan.fromseconds(duration).tostring(); } } } then use in view with
@html.displayfor(modelitem => item.timespan)
Comments
Post a Comment