MultiView and View Web Server Controls Overview
This topic contains:
Provide alternate sets of controls based on user choice or other conditions. For example, you might allow users to select from a list of feeds, each of which is configured in a separate View control. You can then display the View control that contains the user's choice of feeds. You can use the MultiView and View controls as an alternative to creating multiple Panel controls.
Create a multi-page form. The MultiView and View controls can provide behavior that is similar to the Wizard control. The Wizard control is particularly suited to creating forms that users fill in step by step. The Wizard control also includes support for more built-in UI elements, such as a header and footer, for Previous and Next buttons, and for templates. You might use a MultiView control in place of a Wizard if you wanted to create a display that changed based on condition (rather than sequentially), or if you did not need the extra features supported by the Wizard control.
The MultiView control displays one View control at a time, exposing the markup and controls within that View control. By setting the MultiView control's ActiveViewIndex property, you can specify which View control is currently visible.
Rendering View Control Content
If a View control is not selected, it is not rendered to the page. However, instances of all Web server controls in all the View controls are created each time the page is rendered, and their values are stored as part of the page's view state.
Neither the MultiView control nor individual View controls render any markup to the page other than the contents of the current View control. For example, the controls do not render a div element in the same way that a Panel control does. They also do not support appearance properties that can be applied as a whole to the current View control. But you can assign a theme to the MultiView or View controls, which applies the theme to all child controls of the current View control.
Each View control supports a Controls property that contains a collection of the controls in that View control. You can also reference the controls in the View controls individually in code. For details, see Accessing ASP.NET Controls Programmatically.
Navigating Between Views
You can move between views by setting the MultiView control's ActiveViewIndex property to the index value of the View control to display. The MultiView control also includes support for navigation buttons that you can add to each View control.
To create navigation buttons, you can add a button control (Button, LinkButton, or ImageButton) to each View control. You can then set the CommandName and CommandArgument properties of each button to reserved values to cause the MultiView control to move to another view. The following table lists the reserved CommandName values and the corresponding CommandArgument values.
ID of the View control to switch to.
Index number of the View control to switch to.
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> <asp:View ID="View1" runat="server"> View 1<br /> <br /> <asp:Button ID="Button1" runat="server" CommandArgument="View2" CommandName="SwitchViewByID" Text="Go to View2" /> </asp:View> <asp:View ID="View2" runat="server"> View 2<br /> <br /> <asp:Button ID="Button2" runat="server" CommandArgument="View3" CommandName="SwitchViewByID" Text="Go to View 3" /> </asp:View> <asp:View ID="View3" runat="server"> View 3<br /> <br /> <asp:Button ID="Button3" runat="server" CommandArgument="View1" CommandName="SwitchViewByID" Text="Go to View 1" /> </asp:View> </asp:MultiView>
The main class for the MultiView control.
Represents a collection that enables a MultiView control to maintain a list of its child controls.
The main class for the View control.