且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是Asp.net MVC局部视图点

更新时间:2022-11-23 13:19:19

没有区别 - 这是真的。但是,当你说管窥所有你的队友明白,你的意思是将整个网站的许多地方使用可重复使用的意见。

Ive noticed that there seems to be no real difference between a view and a partial view. For instance, one can create a view but can render it as a partial view by using

@Html.Partial("ViewName")

or by specifying that its action return it as

return PartialView();

Ive noticed that the opposite is also the case - ie, one can create a partial view but if it is returned as a full view, it will be displayed with the default layout for the views.

My question is this - When adding a new view in Visual Studio, one is given the option of creating a view that is partial or not. Isn't this redundant, since a view can be rendered as both a partial and a full view anyway?

No difference - it's true. But when you say "Partial View" all your teammates understand that you mean reusable views that will be used in many places across the website.