1st i explain my problem,we are using BootStrap DatePicker, after submit the Html.BeginForm it goes to controller with select date and updating the database in my development system(pc) but the same coding is not working in testing server and client system. After debug on Testing server i found the datepicker return NULL to controller when i choose the Date more than 12 Day e.g (13-10-2014) and for less then 12 date like (12-10-2014) is working fine.
I changed the culture as Invariant but still its return null value to controller
The datepicker defined inside the BeginForm, Other controls are returning the correct values expect the DatePicker.
Html.BeginForm("MergeTeacherDetails","Profile", FormMethod.Post, new { id = "FormTeacherDetails" })))
The DatePicker Format changed as ('dd/mm/yyyy') Here the View Code
@Html.LabelFor(m => m.DOB, "DOB", new { @class = "control-label"})
<div class="controls">
@{System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
@Html.TextBoxFor(model => model.DOB, new { placeholder = "DOB",@readonly = "readonly",@class="ReadOnly" })}
</div>
Here the JavaScript
$('#DOB').datepicker({ startView: 2, autoclose: true, format: "dd/mm/yyyy", endDate: '@DateTime.Now.ToString("dd/MM/yyyy")', changeYear: true, changeMonth: true, weekStart: 1 });
Here the DAL code
public Nullable<System.DateTime> DOB { get; set; }
Here the Controller Code
public ActionResult MergeTeacherDetails(Staffs objStaffs)
{
int res = _staffRepository.InsertOrUpdate(objStaffs);
if(res>0)
{
_mapStaffRepository.SaveMapStaff(objStaffs.StaffId);
}
return RedirectToAction("/MyProfile/1");
}
In controller Parameter objStaffs.DOB is returns as NULL
This
Kindly help me to solve this
Thanks in advance