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:
null
, how can I suppress the display of the default date value?null
, how can I format the date as MM/dd/yyyy
?Use nullable date in your ViewModel:
public DateTime? FromDate { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With