Let’s say you have a TextBoxFor in your page to display a date (based on DateTime in the model):

@Html.TextBoxFor(model => model.dateFrom)

But, since it just displays something like “1/1/0001 12:00:00 AM“, you probably don’t like that.

So, to fix that, what you can do is to give it a default date. For demonstration purposes, we’re going to use the current date:

@Html.TextBoxFor(model => model.dateFrom, new {@Value=@DateTime.Now})

However, this will also show the time, so, to get rid of that, and have the ‘short’ date format, you would do this:

@Html.TextBoxFor(model => model.dateFrom, 
           new {@Value=@DateTime.Now.ToShortDateString()})

That’s all there is to it!