partial view mvc explain code example

Example 1: mvc view vs partial view

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)

Example 2: dynamically load partial view mvc

// partial view controller
public IViewResult LoadPartial() {
  return PartialView("_login"); // name of the partial view
}

// view (with jquery)
$("#container").load("LoadPartial");

Tags:

Misc Example