I am creating a view containing a form in ASP.NET MVC3 for a model containing time spans. I was wondering if there is a way that I can prevent the text box that is rendered from showing the seconds part? So that instead of 12:30:00 , I would get 12:30?
Here is what I have in the model and view:
//model
[Required]
[DataType(DataType.Time)]
public TimeSpan Start { get; set; }
//view
<div class="editor-field">
@Html.EditorFor(model => model.Start)
@Html.ValidationMessageFor(model => model.Start)
</div>
Any advice would be much appreciated.
You could use the
[DisplayFormat]attribute: