1.

What is Partial View in MVC

Answer»

Partial view is a reusable view like the user control in ASP.NET, which can be used as a child view in multiple other views. It reduces the DUPLICATE CODE in the system by reusing the same partial view in multiple views. You can use the partial view in the layout view, as well as other content views.

To render the partial view in the parent view we use  HTML helper methods: Partial() or RenderPartial() or RenderAction(). Each method has different PURPOSES, as follows:

  • The partial helper method renders the given partial view. It ACCEPTS partial view name as a string parameter and RETURNS MvcHtmlString. 
  • RenderPartial helper method is like the Partial method but it returns void and writes resulted in HTML of a specified partial view into an http response stream directly.
  • RenderAction helper method invokes a specified controller and action and renders the result as a partial view. 


Discussion

No Comment Found