dibyendu
0
Q:

mvc view vs 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);
}
0
I think the biggest difference is about the use of the _Layout page:

PartialView(): the razor engine will get the view (e.g. index.cshtml) without any layout page (_layout.cshtml).
View(): the engine will get your view (e.g. index.cshtml) and then appends the content of this view inside the layout page (_layout.cshtml)
0

New to Communities?

Join the community