I am trying to bind the date selected by the DatePicker to the model that is strongly typed to my view. The property inside the model (NewEditDataTypeModel) that I'm trying to bind to is "codeTypeNewEditModel.EffectStartDate". The datatype is DateTime.
My view is strong typed as follows:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TMS.MVC.BusinessSystemsSupport.Models.NewEditDataTypeModel>" %>
** My DatePicker is setup as follows:**
Effective Start Date: <input type="text" id="Model_codeTypeNewEditModel_EffectStartDate" name="Model_codeTypeNewEditModel_EffectStartDate"/>
<script type="text/javascript">
$(document).ready(function () {
$("#Model_codeTypeNewEditModel_EffectStartDate").datepicker({
showOn: 'button',
buttonImage: '/Content/images/calendar.gif',
duration: 0
});
});
My action method is as follows:
[HttpPost]
public ActionResult DataTypeNewEdit(NewEditDataTypeModel newEditDataTypeModel)
{ etc
The newEditDataTypeModel model doesn't populate the effected start date from the DatePicker. Does anyone know what I'm doing wrong? I believe using the underscores is the correct thing to do.