交流意见 [英] Sharing Views

查看:97
本文介绍了交流意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是个好主意,分享不同的控制器之间的意见(通过查看/共享文件夹)?我创造我的第一个MVC应用程序,它需要数据的一些作品是彼此相似。他们解释不同的东西(所以会被存储在不同的表),但他们每个人都有一个ID,名称和状态。因此,我可以用不同的控制器,然后使用相同的视图在下拉列表中显示的数据,让用户选择一个编辑或者通过一个文本框中添加一个新的。很显然,我失去了强类型的ViewPage的数据,但除此之外,这会被认为是做到这一点的好办法还是我的能力,我最好创建每个控制器使用视图?

Is it a good idea to share views between different controllers (using the Views/Shared folder)? I am creating my first MVC application and it requires some pieces of data that are similar to each other. They "explain" different things (and will therefore be stored in different tables) but they each have an Id, Name and Status. I can therefore use different controllers which then use the same View to display the data in a drop down list, allow the user to select one to edit or add a new one via a text box. Obviously I lose the ability to have strongly typed ViewPage data but besides that, would this be considered a good way to do this or am I better off creating a View for each controller to use?

推荐答案

通过我们的项目,我们隔离大多数的意见,控制器和不重用很多人,但我们确实使用了大量的用户控件和部分意见让我们最终不会重复自己。这让我们把一切都强类型为好,也许它可能适合您的方案?

With our project we isolate most of the views to the controllers and don't reuse many of them, but we do use a lot of user controls and partial views so that we don't end up repeating ourselves. This lets us keep everything strongly typed as well, perhaps it might suit your scenario?

这篇关于交流意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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