In my view I have the following:
@Html.TextBoxFor(model => model.EndDate)
When the code and the model is created I see it sets a default date rather than null for the field that’s defined as follows:
public DateTime EndDate { get; set; }
In my view I see the following:
{1/1/0001 12:00:00 AM}
Is there some way that I can make it show/return an empty string if the field is not yet set to a value by my code. Here it just defaults to the above when I create a view and don’t set that field.
DateTime is a value type which cannot have no value.
You have to use nullable of DateTime written like
Now you can assign the
nullvalue to your model in the controller: