开发者

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开发者_如何学JAVA similar but I was curious if there was a difference (other than specifying the template page, etc at the top).


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜