System.Web.UI.WebControls Namespace MultiView Class
Sets or retrieves the index of the active View control within a MultiView control.
Inline |
<asp:multiview activeviewindex = intIndex ... > |
Script |
Multiview.ActiveViewIndex [ = intIndex ] |
intIndex |
Integer specifying the zero-based ordinal index of the active View control within a MultiView control. |
The property is read/write with a default value of -1, indicating that no view is set as active.
Exception Type |
Condition |
ArgumentOutOfRangeException |
The given index is set to less than -1 or greater than or equal to the items count of the list. |
Views in a MultiView are indexed in the order in which they are declared within the document structure.
NOTE: Like most indexes in ASP.NET, ActiveViewIndex is zero-based, meaning the first item in the collection returns an index of 0.
Use the ActiveViewIndex property to specify or determine the index of the selected view within a MultiView.
Only one View control at a time can be defined as active within a MultiView control. The View control that is set as the active view is rendered to the client.
ActiveViewIndex returns a value of -1 if no item is selected, and the MultiView does not render any content to the client. If the ActiveViewIndex is set to a view that does not exist, an ArgumentOutOfRangeException is raised at run time.
The ActiveViewIndex can be set declaratively at design time or programmatically at run time.
Alternatively, the MultiView includes the SetActiveView and GetActiveView methods to set or get the active view within the MultiView control.
The following examples demonstrate using the ActiveViewIndex property to set the active view in a MultiView control.
SetActiveView Method GetActiveView Method Navigating Views in the MultiView Control