• How to create Partial View in ASP.NET MVC?

    by  • November 2, 2015 • Microsoft .NET Framework, Microsoft ASP.NET MVC • 0 Comments

    Partial view is special view which renders a portion of view content. It reduces the complexity of code and can be used within multiple views. It is just like regular view with file extension.cshtml. We can use partial view when the situation like we need a header, footer reuse for the ASP.NET MVC web application. We can say that it’s like a user control concept in asp.net.  We cannot add layout view in partial view.

    The partial view is instantiated with its own copy of a ViewDataDictionary object which is available with the parent view so that partial view can access the data of the parent view.

    Here I am going to explain how to create a partial view in ASP.NET MVC.


    The Model comes to a simple class containing raw data. The source code of the model class is shown below:


    Since there is no server-side processing, the controller class is also fairly simple and it practically does nothing. it is only passing list to view to show data. The controller class used in the example is shown below:


    Add a partial view to view -> index folder with view name _Partial .The best way to create partial view with name preceded by ‘_’, because the name specifying that it is reusable. The PartialView used in the example is shown below:


    The View used in the example is shown below:

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of Abdul Rehman


    Abdul Rehman writes on .NET technologies at GetCodeSnippet.com. GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.


    Leave a Reply