我什么时候应该在asp.net mvc中使用局部视图? [英] when should i use partial views in asp.net mvc?

查看:58
本文介绍了我什么时候应该在asp.net mvc中使用局部视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查看过示例ASP.NET MVC书呆子晚餐应用程序...但是仍然无法理解我应该在何时何地进行局部查看?

I ve gone through sample asp.net mvc nerd dinner application... But still cant understand the point where and when should i go for partial views?

  • 它类似于webformw中的用户控件吗?

注意: 可以看到部分视图正在运行...任何示例...

Note: It would be helpful to see a partial view in action... Any sample...

推荐答案

任何您要使用的都不止一次.例如,在此SO页面上,您会在右侧看到相关帖子的列表.那是在多个页面上,所以为什么要多次创建它.您可以将数据传递到部分视图以根据特定条件对其进行自定义.

Anything you would use more than once. For instance on this page for SO, you see the listing of related posts over to the right. That is on multiple page, so why create it multiple times. You can pass data to the partial view to customize it based on certain criteria.

在某些情况下,例如登录,我不喜欢它,我希望将用户带到登录页面.但是,这种情况经常使用.

I do not like it for certain things like login, where I would rather take the user to a login page. However that scenario is used often.

这篇关于我什么时候应该在asp.net mvc中使用局部视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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