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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -