什么是Asp.net MVC局部视图点 [英] What is the point of Partial Views in Asp.net MVC

查看:118
本文介绍了什么是Asp.net MVC局部视图点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

香港专业教育学院发现,似乎有一个视图和局部视图之间没有真正的区别。
例如,你可以创建一个查看,但可以用它呈现为一个局部视图

  @ Html.Partial(视图名)

通过指定它的行动回报为

 返回PartialView();

香港专业教育学院注意到,相反的情况也是如此 - 也就是说,你可以创建一个局部视图,但如果它返回为一个完整的视图,它会与视图的默认布局显示

我的问题是这样的 -
当添加在Visual Studio中的新观点,给出一个创造一种观点认为是局部的或不是的选项。这不是多余的,因为视图可以呈现为两个部分,反正一个完整的看法?


解决方案

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

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.

这篇关于什么是Asp.net MVC局部视图点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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