I am not looking to use the ajax jQuery method. I would like to use the .load() method for a div. Here's what my javascript method looks like:
function PartialViewLoadArray(aName, aValue, aGuid, aName2, aValue2, aGuid2) {
modelArray = [];
modelArray.push({ Name: aName, Value: aValue, Guid: aGuid });
modelArray.push({ Name: aName2, Value: aValue2, Guid: aGuid2 });
$('#examplediv').load(
'/Example/PartialByModelArray/',
{ ModelArray: modelArray },
function () {
alert('the load has completed!');
}
);
}
Here is the action on the controller:
public PartialViewResult PartialByModelArray(ExamplePartialArrayModel aModel)
{
return PartialView("_ExamplePartialByArray", aModel);
}
My array model:
public class ExamplePartialArrayModel
{
public ExamplePartialModel[] ModelArray { get; set; }
}
The model contained in the above model:
public class ExamplePartialModel
{
private string _Name;
private int? _Value;
private string _Guid;
public string Name
{
get { return this._Name; }
set { this._Name = value; }
}
public int? Value
{
get { return this._Value; }
set { this._Value = value; }
}
public string Guid
{
get { return this._Guid; }
set { this._Guid = value; }
}
}
I know I can get this div to load the content if I render the partial view manually using the context and a stringwriter, etc, but it seems to me as though I should be able to get this load() statement to work. Why isn't MVC picking this data up? What is EXTREMELY odd is that when I set a breakpoint on the first line of my action it's showing me two items in the array--but all their properties are null. How can it determine the amount of items in the array but not bind their values? What is going on? I am mystified.