Partial View in ASP.NET MVC

Partial View in ASP.NET MVC like a  User Control in ASP.NET Web Forms. In order to reuse a View in our MVC application (For example, use a header, list of items or footer etc.), Partial Views are introduced that basically renders inside a Parent View.

Let’s give an example to understand the concept of Partial Views in more simple and better way. Consider we have list of our company products being displayed on Products page of our website. Now, we want to have another web page “Search Product” where we need to display the list of products in same manner but filtered according to a search criteria.

Now, In order to display list of products on “Search Product” page, we have two options:
1. Rewrite all HTML and Code for displaying product list.
2. Or, develop an ASP.NET MVC Partial View for product listing and use on both pages.

Partial View Advantages in ASP.NET MVC

So, using Partial View in ASP.NET MVC has following advantages:

  • Enhances reusability by packaging up common website code instead of repeating the same in different pages.
  • Easy to maintain. Changes in future are simple to accommodate.

Rendering a Partial View inside another View is quite simple by using Html.RenderPartial function and passing Partial view name as parameter to it.


2 thoughts on “Partial View in ASP.NET MVC

Author gravatar
christmas light installation summit October 18, 2017, 8:20 pm

Howdy would you mnd sharing which blog platform
you’re working with? I’m looking to start mmy own blog in the
near future but I’m having a tough ime selecting between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your design seems different then most blogs and I’m loiking for something
completely unique. P.S Sorry for getting off-topic but I had to ask!

essayforme May 15, 2018, 4:02 pm

Superb information. Regards.

Leave a Reply

Your email address will not be published. Required fields are marked *