Hello,
I am using the below code in MVC partial view to give an option for the user to select date?
@Html.DatePickerFor(m => m.ReasonData.ReasonModels[0].Ravi.BeginDate, new { @class = "RaviDate" })
and have the below code to control the format..
var builder = new StringBuilder();
builder.Append(@"<script type='text/javascript'>$(document).ready(function () {
$('#");
builder.Append(controlId);
builder.Append(@"').datepicker({
showOn: 'button',
buttonImage: 'Content/Images/Correspondance/calendar.gif',
duration: 0,
changeMonth: true,
changeYear: true,
dateFormat:'mm/dd/yy'});
});
</script>");
for example when user selects the date, it would display it in the correct format which I wanted as 09/23/2014....
but if user goes to next page and come back to the previous page, it is displaying the date as 9/23/2014 12:00:00 AM, which is what I don't want....
This is how I have the model property defined..
[Required(ErrorMessage = "A lapse date must be entered.")]
[DisplayName("When did the policy lapse?")]
[DisplayFormat(DataFormatString = "{mm/dd/yy}", ApplyFormatInEditMode = true)]
public DateTime? BeginDate { get; set; }
Please let me know how I can fix the date format?