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 SinghRank #643 · 3.7K reputationPosted Apr 10, 2015, 8:52 PM EDT
Mahesh Patil17 reputationPosted Apr 11, 2015, 12:44 AM EDT
$('#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 SinghRank #643 · 3.7K reputationPosted Apr 11, 2015, 2:46 AM EDT
[httppost]
public ActionResult MyAction(FormCollection fc)
{
var data =fc["ConsumerServiceAndPeriod.TimesheetID"];
}
remove _ to . in this case.