Hi,
In my mvc3 project i have an entity as below
--------------------------------------------
public class Entity
{
public int iErrorId { get; set; }
}
then using javascript call a function in a controller and pass the
object array as below,
---------------------------------------------------
unction SaveTrackChanges() {
var _trackChanges = {};
for (i = 0; i < _drpErrorType.length; i++) {
_trackChanges["iErrorId"] = document.getElementById(_drpErrorType[i]).options[document.getElementById(_drpErrorType[i]).selectedIndex].value;
}
$.ajax({
type: "POST",
url: "../Home/SaveTrackChanges",
contentType: "application/json",
data: JSON.stringify({_trackChanges: _trackChanges}),
error: function (xhr, textStatus) {
alert("Error while processing the request, please try again.");
ShowHideProcessing(0);
},
success: function (result, textStatus) {
}
});
}
In controller the function SaveTrackChanges as below :-
--------------------------------------------------
public JsonResult SaveTrackChanges(Entity _trackChanges)
{
using (wordscriptEntities dbContext = new wordscriptEntities())
{
return Json("1");
}
}
My doubt is how to iterate through the class property values?
that is, the above code 'iErrorId' as more than one value and pass this value to the controller function.
then, how to loop through this value in 'SaveTrackChanges' function?
Thanks..