views:

1270

answers:

5

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.

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?

+3  A: 

I've used it in the passed to implement a simple Ajax-enabled tab interface.

Style a button to look like a tab, then set it's onClick event to switch the active view in an update panel.

Rob Allen
+8  A: 

I have used MultiViews as a more flexible basis for a Wizard control.

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.

Brownie
A: 

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.

Max Schmeling
A: 

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.

Dan Diplo
+2  A: 

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.

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.

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.

richeym