What are some scenarios where MultiView would be a good choice? The MultiView control along with its View controls simply seem to extend the notion of Panels.
在什么情况下MultiView会是一个不错的选择? MultiView控件及其View控件似乎只是扩展了Panel的概念。
Both Panels and MultiViews seem prone to abuse. If your UI concerns and biz logic concerns are properly separated, why lump views together in a single ASPX?
Panels和MultiViews似乎都容易被滥用。如果您的UI问题和业务逻辑问题被正确分开,为什么要在一个ASPX中将视图混合在一起?
5 个解决方案
#1
11
I have used MultiViews as a more flexible basis for a Wizard control.
我使用MultiViews作为Wizard控件的更灵活的基础。
I do agree that lumping lots of views together is a code smell. In the case of a wizard there are often lots of pieces of state you want to share throughout the process. The multiview allows this state to be simply stored in the viewstate.
我同意将大量观点混为一谈是一种代码味道。在向导的情况下,在整个过程中通常会有很多状态。多视图允许将此状态简单地存储在视图状态中。
Most of the time I make the contents of each view a single user control that it can encapsulate the logic related to that particular step.
大多数情况下,我将每个视图的内容设为单个用户控件,以便它可以封装与该特定步骤相关的逻辑。
#2
3
I've used it in the passed to implement a simple Ajax-enabled tab interface.
我在传递中使用它来实现一个简单的启用Ajax的选项卡界面。
Style a button to look like a tab, then set it's onClick event to switch the active view in an update panel.
将按钮设置为类似于选项卡的样式,然后将其设置为onClick事件以在更新面板中切换活动视图。
#3
3
Any situation where you find yourself toggling the display of one or more panels is a prime candidate for a MultiView control. A more templated wizard control, or master / detail forms for example.
您发现自己切换一个或多个面板的显示的任何情况都是MultiView控件的主要候选者。例如,更模板化的向导控件或主/详细信息表单。
I agree that they are open for abuse and you should evaluate whether you're better off separating your code into separate pages before using them. I've worked on projects where the previous developer has tried to put too much onto a single page using MultiViews and they are sheer hell to work with.
我同意他们对滥用行为持开放态度,您应该评估在使用它们之前是否最好将代码分成单独的页面。我曾经在上一个开发人员尝试使用MultiViews过多地放在单个页面上的项目上工作,而且他们完全可以使用它们。
One thing to be wary of with MultiViews is that unlike panels, any declarative datasource controls contained inside them will always bind, even when the view they are contained in is not active / visible.
使用MultiViews要警惕的一件事是,与面板不同,包含在其中的任何声明性数据源控件将始终绑定,即使它们包含的视图不是活动/可见的。
#4
0
Any time that you want to show different content on a page based on some condition. At work I've created a tab control that just uses a MultiView and another simple control I made that looks like tabs. Each tabs puts a link (which is styled) in the other control that is wired up to set the active view to the correct tab.
任何时候您想根据某些条件在页面上显示不同的内容。在工作中我创建了一个选项卡控件,它只使用了MultiView和另一个我制作的简单控件。每个选项卡都会在另一个控件中放置一个链接(样式化),该控件连接起来将活动视图设置为正确的选项卡。
#5
0
It can be useful for things like online forms, where you may have one view showing the actual form and another view displayed afterword with the "thank you" text etc.
它可以用于在线表单之类的内容,您可以在其中显示一个显示实际表单的视图,使用“谢谢”文本显示另一个显示后的视图。
#1
11
I have used MultiViews as a more flexible basis for a Wizard control.
我使用MultiViews作为Wizard控件的更灵活的基础。
I do agree that lumping lots of views together is a code smell. In the case of a wizard there are often lots of pieces of state you want to share throughout the process. The multiview allows this state to be simply stored in the viewstate.
我同意将大量观点混为一谈是一种代码味道。在向导的情况下,在整个过程中通常会有很多状态。多视图允许将此状态简单地存储在视图状态中。
Most of the time I make the contents of each view a single user control that it can encapsulate the logic related to that particular step.
大多数情况下,我将每个视图的内容设为单个用户控件,以便它可以封装与该特定步骤相关的逻辑。
#2
3
I've used it in the passed to implement a simple Ajax-enabled tab interface.
我在传递中使用它来实现一个简单的启用Ajax的选项卡界面。
Style a button to look like a tab, then set it's onClick event to switch the active view in an update panel.
将按钮设置为类似于选项卡的样式,然后将其设置为onClick事件以在更新面板中切换活动视图。
#3
3
Any situation where you find yourself toggling the display of one or more panels is a prime candidate for a MultiView control. A more templated wizard control, or master / detail forms for example.
您发现自己切换一个或多个面板的显示的任何情况都是MultiView控件的主要候选者。例如,更模板化的向导控件或主/详细信息表单。
I agree that they are open for abuse and you should evaluate whether you're better off separating your code into separate pages before using them. I've worked on projects where the previous developer has tried to put too much onto a single page using MultiViews and they are sheer hell to work with.
我同意他们对滥用行为持开放态度,您应该评估在使用它们之前是否最好将代码分成单独的页面。我曾经在上一个开发人员尝试使用MultiViews过多地放在单个页面上的项目上工作,而且他们完全可以使用它们。
One thing to be wary of with MultiViews is that unlike panels, any declarative datasource controls contained inside them will always bind, even when the view they are contained in is not active / visible.
使用MultiViews要警惕的一件事是,与面板不同,包含在其中的任何声明性数据源控件将始终绑定,即使它们包含的视图不是活动/可见的。
#4
0
Any time that you want to show different content on a page based on some condition. At work I've created a tab control that just uses a MultiView and another simple control I made that looks like tabs. Each tabs puts a link (which is styled) in the other control that is wired up to set the active view to the correct tab.
任何时候您想根据某些条件在页面上显示不同的内容。在工作中我创建了一个选项卡控件,它只使用了MultiView和另一个我制作的简单控件。每个选项卡都会在另一个控件中放置一个链接(样式化),该控件连接起来将活动视图设置为正确的选项卡。
#5
0
It can be useful for things like online forms, where you may have one view showing the actual form and another view displayed afterword with the "thank you" text etc.
它可以用于在线表单之类的内容,您可以在其中显示一个显示实际表单的视图,使用“谢谢”文本显示另一个显示后的视图。