是什么视图,并在ASP.NET MVC一个PartialView之间的区别? [英] What is the difference between a View and a PartialView in ASP.NET MVC?
问题描述
是什么查看和ASP.NET MVC一个PartialView区别?
What is the difference between a View and a PartialView in ASP.NET MVC?
乍一看需要双方似乎不明显给我。
At first glance the need for both seems non-obvious to me.
推荐答案
在理论上,答案是:的部分观点是,你嵌入主视图中的一个子视图 - 东西,你可能会重用跨多个视图,就像一个侧边栏。的
在实践中,答案是:很少
在理论上,局部视图比标准的看法更为轻巧,但它是完全确定通过一项常规,以的RenderPartial
和性能似乎是如出一辙。我经常使用常规的.aspx意见部分的观点,因为你可以让他们以提供像您可以在ASP.NET的WebForms用户控件做模板化内容中引用的主视图。见<一href=\"http://jeffreypalermo.com/blog/asp-net-mvc-and-the-templated-partial-view-death-to-ascx/\">here.
In theory, partial views are more lightweight than standard views, but it's perfectly OK to pass a "regular" view to RenderPartial
and the performance seems to be exactly the same. I frequently use regular .aspx views as "partial" views because you can make them reference a master view in order to provide templated content like what you can do with UserControls in ASP.NET WebForms. See here.
部分观点更像一个门户网站的Web部件 - 他们是完全独立的对象。使用他们,如果布局简单而静态的,或者如果你是恼火通过智能感知错误,当你不具备&LT; HTML&GT;
和&LT;车身方式&gt;
标签标准视图
Partial views are more like web parts on a portal - they are completely self-contained objects. Use them if the layout is simple and static, or if you're annoyed by the Intellisense errors when you don't have the <html>
and <body>
tags in a standard View.
这篇关于是什么视图,并在ASP.NET MVC一个PartialView之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!