Steve Sloka
Steve Sloka

Reputation: 3454

MVC3 Partial View vs. Regular View

Just curious if there was anything that made a partial view different from a regular view other than convention.

Code-wise they look and work similar but I was curious if there was a difference (other than specifying the template page, etc at the top).

Upvotes: 27

Views: 11647

Answers (3)

M80
M80

Reputation: 994

Maybe "PartialView" are generally clubbed with [ChildActionOnly] so that it is used in man page by invoking actions using HTMl.Action etc.

Upvotes: 0

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93424

If you're using Razor, there is no real difference between a partial view and a view, they're both cshtml files. A view is a view. If you want to use a view as a partial view, then there are some restrictions, such as not using a Layout file.

In WebForms View engine, a partial view is typically an ascx, versus an aspx. There are some subtle differences there in the definitions, but they're still largely interchangeable.

Partial versus full is all about the way it's used. If you return the view in a View() method, it's a full view. If you return it in a Partial, then it's a partial.

Upvotes: 19

Iridio
Iridio

Reputation: 9271

To put it simply PartialViews are not Views.

The way the code works is the same, but the way you use them is not. PartialView are more like a user control of Asp.NET. This post should give you more info

Upvotes: 2

Related Questions