We learned a great deal about the Partial Views in my post Fundamentals of MVC Partial Views. In this post I’ll show you how to create a partial view in a Visual Studio MVC 3 project and how to load the partial view inside a regular view using the following two methods:
- Server side using Html.Partial() helper method
- Client side using jQuery load() method into an empty div element inside a regular view
Step 1. Create a MVC project called ChalakiPartialViews
I’ll be using C# and Razor views for this project. Start with creating new C# MVC3 project. You can also use VB if you wish. The solution, project and the related files are created in their default folder structure.
Step 2. Create the Book model
Use the supplied books.sdf SQL compact db file and create a Book Model to match the Books table.
namespace ChalakiPartialViews.Models
{
public class Book
{
public int ID { get; set; }
public string Title { get; set; }
public string Memo { get; set; }
}
public class BookDBContext : DbContext
{
public DbSet<Book> Books { get; set; }
}
}
The connection string points to the Books.sdf as shown:
<add name="BookDBContext"
connectionString="Data Source=|DataDirectory|Books.sdf"
providerName="System.Data.SqlServerCe.4.0"/>

