Answers for ".net mvc return only viewdata from a partial controller?"

3

mvc return view from different controller

return View("~/Views/SomeThing/Index.cshtml");
return View("~/Views/SomeThing/Index.cshtml",model);
Posted by: Guest on December-10-2020
2

c# mvc return partial view

// Create a container for your data
<div id="ViewHolder"><div>

//You can call your method using ajax:
$.ajax({
	type: "POST",
	url: '<Your path to your controller>/GetView',
	contentType: "application/text; charset=utf-8",
	dataType: "text",
	async: false,
	success: function (data) {
		// Populate your container
		$('ViewHolder').html(data);
	}
})

// In your controller 
public PartialViewResult GetView()
{
	//Passing a model is optional
  	MyModel myModel = new MyMyodel();
	return PartialView("<Your View Name>", myModel);
}
Posted by: Guest on September-29-2020

Code answers related to ".net mvc return only viewdata from a partial controller?"

Browse Popular Code Answers by Language