How to set value to a datepicker through Javascript ()???
New DiscussionMy JAVASCRIPT Function in View:
<script type=”text/javascript”>
$(function () {
function ProgrammeAllotmentModel() {
this.ProposalDetailsIDKey = “”;
}
$(document).delegate(“.ddlProposalDetail”, “igcomboselectionchanged”,
function (evt, ui) {
var id = evt.target.id;
if (ui.items && ui.items[0]) {
var myRecipe = new ProgrammeAllotmentModel();
myRecipe.ProposalDetailsIDKey = ui.items[0].value;
var postData = JSON.stringify(myRecipe);
$.ajax({
url: ‘@Url.Action(“/LoadProposalDetailsByIDKey”)’,
type: ‘POST’,
data: JSON.stringify(myRecipe),
dataType: ‘json’,
contentType: ‘application/json; charset=utf-8’,
success: function (obj) {
var num = id.replace(“ddlProposalDetail”, “”);
alert(num);
$.each(obj, function (key, value) {
alert(value.TentativeFromDateDt);
$(“#TentativeStartDate” + num).igDatePicker(value.TentativeFromDateDt, new Date());
});
},
error: function () {
alert(‘error occured’);
}
});
}
});
});
</script>
Am rendering a partial view which has a datepicker in it.
My partial view :
<td>
@Html.Infragistics().DatePickerFor(model => model.MyProperty[j].TentativeStartDate).ID(“TentativeStartDate” + j).DateInputFormat(“dd/MM/yyyy”).Width(100).Height(22).ValidatorOptions(m => m.Required(false)).Render()
</td>
My controller function returns TentativeFromDateDt Property as {6/25/2014 9:34:59 PM}
Mt model class contains
public Nullable<System.DateTime> TentativeFromDateDt { get; set; }
My alert box in javascript () shows:
/Date(1403712299050)/