JavaScript Editor jscript editor     Web designer 

Main Page

The MultiView and View Web server controls act as containers for other controls and markup, and provide a way for you to easily present alternate views of information. You can use the MultiView and View controls to perform tasks such as the following:

MultiView and View Structure

The MultiView control acts as an outer container for one or more View controls. The View controls, in turn, can contain any combination of markup and controls.

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 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. However, 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.

Referencing Controls

Each View control supports a Controls property that contains a collection of the controls in that View control. However, you can 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.

CommandName value CommandArgument value


(no value)


(no value)


ID of the View control to switch to.


Index number of the View control to switch to.

The following example shows a MultiView control with three View controls. Each View control contains a Button control that moves to a specific View control.

В CopyCode imageCopy Code
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
  <asp:View ID="View1" runat="server">
    View 1<br />
    <br />
    <asp:Button ID="Button1" runat="server" 
      Text="Go to View2" />
  <asp:View ID="View2" runat="server">
    View 2<br />
    <br />
    <asp:Button ID="Button2" runat="server" 
      Text="Go to View 3" />
  <asp:View ID="View3" runat="server">
    View 3<br />
    <br />
    <asp:Button ID="Button3" runat="server" 
      Text=Go to View 1" />

See Also

JavaScript Editor jscript editor     Web designer