MultiView::SwitchViewByIndexCommandName Field
Assembly: System.Web (in System.Web.dll)
Use the SwitchViewByIndexCommandName field to represent the "SwitchViewByIndex" command name.
You can use the value of this field to take advantage of the MultiView control's automatic updating of the active View control. For example, if a View control contains a Button control that navigates to the first View when clicked, you can set the CommandName property to the value of the SwitchViewByIndexCommandName field, which is "SwitchViewByIndex". Set the CommandArgument property to the index of the first View in the MultiView control, which is 0. This causes the MultiView control to automatically set the ActiveViewIndex property to 0 when the button is clicked.
The following code example demonstrates how to use a MultiView control to create a basic survey. Each View control is a separate survey question. The PreviousViewCommandName and NextViewCommandName fields are used to provide automatic navigation between the previous and next View controls in the survey. If the user clicks the Retake Survey button in the last View of the survey, the SwitchViewByIndexCommandName field is used along with a command argument of 0 to redirect the user back to the first View of the survey.
Note |
|---|
The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note