部分视图和布局视图之间的区别 [英] Difference between Partial View and Layout View

查看:253
本文介绍了部分视图和布局视图之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部分视图和布局视图之间的区别?



并告诉如何使用局部视图来避免在父视图中渲染其他视图?

解决方案

部分视图用于显示重复的夏季信息(如ASP.NET Web窗体中的用户控件)



布局视图是为每个块具有不同部分的应用程序而设计的,并且为整个Web应用程序显示相同的布局(如ASP.Net Web窗体中的Master Page)



局部视图只需渲染自己而不用调用他的paranet。



你可以通过jQuery调用部分视图/ Javascript意味着部分视图可以调用Ajax或Ajah。



假设您正在开发ASP.NET Web应用程序,并且希望在Web应用程序中的所有页面上保持一致的外观。然后你有两个选择,第一个是在每个页面上设计头部,主体和页脚部分。在这种方法中,您需要在每个页面上编写更多代码,以便ASP.NET 2.0引入母版页,这有助于在使用基于.aspx的页面或模板时启用此功能。这是你的第二选择。 Razor还支持这一概念,其功能称为布局,允许您定义公共网站模板,然后在Web应用程序的所有视图/页面上继承其外观。


在Sandeep解决方案之上。了解更多

请阅读这篇优秀文件 ASP.NET MVC特殊视图 - 部分视图和布局 [ ^ ]

注意:下载zip文件并阅读 PDF

Difference between Partial View and Layout View ?

and tell how can partial view be used to avoid rendering other view in the parent view ?

解决方案

Partial View is used to display repeated summering information (like user control in ASP.NET Web Form)

Layout View is designed for the application that has different section for each block and to display same layout to entire web application (Like Master Page in ASP.Net Web Form)

Partial view just render itself without calling his paranet.

you can call partial view by jQuery/Javascript means partial view can be calling use Ajax or Ajah.

Suppose you are developing an ASP.NET web application and you want to maintain a consistent look and feel across all the pages within you web application. You then have two options, the first one is to design the head, body and footer sections on each page. In this approach you need to write more code on each page so ASP.NET 2.0 introduced "Master Pages" that helps enable this when using .aspx based pages or templates. It is your second option. Razor also supports this concept with a feature called "layouts" that allow you to define a common site template, and then inherit its look and feel across all the views/pages on your web application.


On top of Sandeep solution. to know more
Please read this excellent document ASP.NET MVC Special Views - Partial View and Layout[^]
note: download the zip file and Read the PDF


这篇关于部分视图和布局视图之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆