I can't update the view model.
I have view called: Overview
I have this in the view's controller:
public ActionResult Overview()
{
var evo = new OverviewViewObject
{
MvcGridModel = new MvcGrid(),
SingleExportData = new SingleExportData()
};
return View(evo);
}
Then i have Save The buttons calles:
$.ajax({
url: saveUrl,
cache: false,
type: "post",
data: JSON.stringify({ Name: myName }),
contentType: "application/json",
success: function (data) { .. }...
the saveUrl goes to:
[HttpPost]
public ActionResult Save(MyDataType saveData)
{
//todo save logic here
var mvcGridModel = GetGridData();
var evo = new ExportDataOverviewViewObject
{
MvcGridModel = mvcGridModel ?? new MvcGrid(),
SaveData = new MyDataType()
};
return View("Overview", evo);
}
And it goes fine in the Save, and it get fine the data in the saveData object, and it doens't return any error till the end, but when after the return it shows the view,the data is not displayed there anymore.
Could you please help me?
A couple of remarks:
return View()
) instead of a partial view which is what is more common for controller actions that are being invoked with AJAX.So to recap:
and your controller action: