.net mvc return only viewdata from a partial controller? code example
Example 1: mvc return view from different controller
return View("~/Views/SomeThing/Index.cshtml");
return View("~/Views/SomeThing/Index.cshtml",model);
Example 2: c# mvc return partial view
<div id="ViewHolder"><div>
$.ajax({
type: "POST",
url: '<Your path to your controller>/GetView',
contentType: "application/text; charset=utf-8",
dataType: "text",
async: false,
success: function (data) {
$('ViewHolder').html(data);
}
})
public PartialViewResult GetView()
{
MyModel myModel = new MyMyodel();
return PartialView("<Your View Name>", myModel);
}