Answers for "c# mvc return partial view"

C#
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

C# Answers by Framework

Browse Popular Code Answers by Language