I would like to do something like
model.PickupDate.ToString("d")
But MVC4 is not liking that very much. PickupDate
is a DateTime
field and I would like to strip off the time portion when displayed in the view, while keeping the new { id = "date1" }
code which binds the TextBoxFor
to the javasript datepicker. How can I display the Date portion only in this instance?
@Html.TextBoxFor(model => model.PickupDate, new { id = "date1" })
this is how I would do this. Hope it helps
@Html.TextBoxFor(m => m.MyDateTime, new { Value = Model.MyDateTime.ToString("MM-dd-yyyy"), id = "MySuperCoolId"});
or in your case
@Html.TextBoxFor(m => m.PickupDated, new { Value = Model.PickupDate.ToString("d"), id = "date1"});
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