Hiding the default value for a date
asp.net-mvc-3, datetime, html.textboxfor
Solution
Use nullable date in your ViewModel:
public DateTime? FromDate { get; set; }
Problem
My View Model: ``` public partial class FileTransferFilterCriteriaViewModel { public string Fice { get; set; } public string SourceEmail { get; set; } public string TargetEmail { get; set; } public DateTime FromDate { get; set; } public DateTime ToDate { get; set; } public string Status { get; set; } public string Category { get; set; } } ``` (Nothing is coming from the DB.) My Controller: ``` return View(new FileTransferFilterCriteriaViewModel()) ``` Here is what gets displayed for both `FromDate` and `ToDate`: ``` 1/1/0001 12:00:00 AM ``` My HTML: ``` @Html.TextBoxFor(x =>x.Criteria.FromDate) ``` Questions: - If the date is `null`, how can I suppress the display of the default date value? - If the date is not `null`, how can I format the date as `MM/dd/yyyy`?