Hello
I want to bind MVC model in ajax call responce like
$.ajax({
async: false,
url: $('#ajaxURLclockoutDetails').val(),
type: 'GET',
cache: false,
data: {
newServiceCode: Selectedvalue,
'ConsumerServiceAndPeriod.ConsumerID': $('#DConsumerID').val()
},
success: function (result) {
1) $('#ConsumerServiceAndPeriod.TimesheetID').val(result.TimesheetID);
or
2) @Html.HiddenFor(m => m.TimesheetID, new { Value =@<%'$("#DConsumerID").val()'%> })
3)@Html.Hidden("ConsumerServiceAndPeriod.TimesheetID", result.TimesheetID)
}
i have mention three possible ways for binding model but no any of them worked
so any one can help me about
bind ConsumerServiceAndPeriod model in ajax responce method
Thanks in advance

Anupam SinghPosted Apr 11, 2015, 6:46 AM
[httppost]
public ActionResult MyAction(FormCollection fc)
{
var data =fc["ConsumerServiceAndPeriod.TimesheetID"];
}
remove _ to . in this case.
Mahesh PatilPosted Apr 11, 2015, 4:44 AM
$('#ConsumerServiceAndPeriod_TimesheetID').val(result.TimesheetID);
This type of hidden field i was bind but cant access this hidden field in controller .
using function like
var data= Request.Form["ConsumerServiceAndPeriod_TimesheetID"];
on the view data was bind but whenever you navigate to controller
this value will be blank.
is there any other way to fetch this value
Anupam SinghPosted Apr 11, 2015, 12:52 AM