MultiView.ActiveViewIndex プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As MultiView Dim value As Integer value = instance.ActiveViewIndex instance.ActiveViewIndex = value
/** @property */ public int get_ActiveViewIndex () /** @property */ public void set_ActiveViewIndex (int value)
MultiView コントロール内のアクティブな View コントロールの 0 から始まるインデックス。既定値は -1 で、アクティブとして設定されているビューがないことを示します。


MultiView コントロール内の View コントロールをアクティブ ビューとして設定するには、ActiveViewIndex プロパティを使用します。このプロパティを使用して、現在アクティブ ウィンドウとして設定されている View コントロールのインデックスを返すこともできます。View コントロールのインデックスは、MultiView コントロール内に宣言されている順序に従って決定されます。たとえば、MultiView 内で 1 番目に宣言されている View コントロールのインデックスは 0 になります。
一度に 1 つの View コントロールだけを MultiView コントロール内でアクティブとして定義できます。ActiveViewIndex プロパティに設定されている View コントロールがクライアントに表示されます。MultiView コントロール内に存在しない View が ActiveViewIndex プロパティに設定されている場合は、実行時に ArgumentOutOfRangeException が発生します。このプロパティが空の場合、MultiView コントロールの内容はクライアントに表示されません。
ActiveViewIndex プロパティは、開発時に宣言によって設定することも、実行時にプログラムによって設定することもできます。MultiView コントロールを定義するときに、宣言によって ActiveViewIndex プロパティを設定すると、MultiView コントロールが初めて呼び出されたときに、アクティブ ビューとして設定されている View コントロールがクライアントに表示されます。ActiveViewIndex プロパティをプログラムによって設定することにより、アプリケーションはユーザー ID やユーザー設定などの基準に基づいて、実行時にクライアントに表示する View コントロールを決定できます。
または、SetActiveView メソッドと GetActiveView メソッドを使用して、MultiView コントロール内のアクティブ ビューを設定または取得できます。
Topic | Location |
---|---|
方法 : Web フォーム ページに MultiView Web サーバー コントロールを追加する (Visual Studio) | Visual Studio での ASP .NET Web アプリケーションの作成 |

MultiView コントロールを使用して基本調査を作成する方法のコード例を次に示します。各 View コントロールは、個別の調査質問です。ユーザーが任意のページの [戻る] ボタンをクリックすると、ActiveViewIndex プロパティの値が減分され、直前の View コントロールに移動します。ユーザーが任意のページの [次へ] ボタンをクリックすると、ActiveViewIndex プロパティの値が増分され、次の View コントロールに移動します。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" %> <html> <head> <script runat="server"> Sub NextButton_Command(sender As Object, e As System.EventArgs) ' Determine which button was clicked ' and set the ActiveViewIndex property to ' the view selected by the user. If (DevPollMultiView.ActiveViewIndex > -1) AND DevPollMultiView.ActiveViewIndex < 3 Then ' Increment the ActiveViewIndex property ' by one to advance to the next view. DevPollMultiView.ActiveViewIndex += 1 ElseIf DevPollMultiView.ActiveViewIndex = 3 Then ' This is the final view. ' The user wants to save the survey results. ' Insert code here to save survey results. ' Disable the navigation buttons. Page4Save.Enabled = False Page4Restart.Enabled = False Else Throw New Exception("An error occurred.") End If End Sub Sub BackButton_Command(ByVal sender As Object, ByVal e As System.EventArgs) If (DevPollMultiView.ActiveViewIndex > 0) And DevPollMultiView.ActiveViewIndex <= 2 Then ' Decrement the ActiveViewIndex property ' by one to return to the previous view. DevPollMultiView.ActiveViewIndex -= 1 ElseIf DevPollMultiView.ActiveViewIndex = 3 Then ' This is the final view. ' The user wants to restart the survey. ' Return to the first view. DevPollMultiView.ActiveViewIndex = 0 Else Throw New Exception("An error occurred.") End If End Sub </script> </head> <body> <form ID="Form1" runat="Server"> <h3>MultiView ActiveViewIndex Example</h3> <asp:Panel id="Page1ViewPanel" Width="330px" Height="150px" HorizontalAlign =Left Font-size="12" BackColor="#C0C0FF" BorderColor="#404040" BorderStyle="Double" runat="Server"> <asp:MultiView id="DevPollMultiView" ActiveViewIndex=0 runat="Server"> <asp:View id="Page1" runat="Server"> <asp:Label id="Page1Label" Font-bold="true" Text="What kind of applications do you develop?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page1Radio1" Text="Web Applications" Checked="False" GroupName="RadioGroup1" runat="server" > </asp:RadioButton><br> <asp:RadioButton id="Page1Radio2" Text="Windows Forms Applications" Checked="False" GroupName="RadioGroup1" runat="server" > </asp:RadioButton><br><br><br> <asp:Button id="Page1Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat= "Server"> </asp:Button> </asp:View> <asp:View id="Page2" runat="Server"> <asp:Label id="Page2Label" Font-bold="true" Text="How long have you been a developer?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page2Radio1" Text="Less than five years" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page2Radio2" Text="More than five years" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br><br><br> <asp:Button id="Page2Back" Text = "Previous" OnClick="BackButton_Command" Height="25" Width="70" runat= "Server"> </asp:Button> <asp:Button id="Page2Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat="Server"> </asp:Button> </asp:View> <asp:View id="Page3" runat="Server"> <asp:Label id="Page3Label1" Font-bold="true" Text= "What is your primary programming language?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page3Radio1" Text="Visual Basic .NET" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page3Radio2" Text="C#" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page3Radio3" Text="C++" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br><br> <asp:Button id="Page3Back" Text = "Previous" OnClick="BackButton_Command" Height="25" Width="70" runat="Server"> </asp:Button> <asp:Button id="Page3Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat="Server"> </asp:Button><br> </asp:View> <asp:View id="Page4" runat="Server"> <asp:Label id="Label1" Font-bold="true" Text = "Thank you for taking the survey." runat="Server"> </asp:Label> <br><br><br><br><br><br> <asp:Button id="Page4Save" Text = "Save Responses" OnClick="NextButton_Command" Height="25" Width="110" runat="Server"> </asp:Button> <asp:Button id="Page4Restart" Text = "Retake Survey" OnClick="BackButton_Command" Height="25" Width="110" runat= "Server"> </asp:Button> </asp:View> </asp:MultiView> </asp:Panel> </form> </body> </html>
<%@ Page Language="C#" %> <html> <head> <script runat="server"> protected void NextButton_Command(object sender, EventArgs e) { // Determine which button was clicked // and set the ActiveViewIndex property to // the view selected by the user. if (DevPollMultiView.ActiveViewIndex > -1 & DevPollMultiView.ActiveViewIndex < 3) { // Increment the ActiveViewIndex property // by one to advance to the next view. DevPollMultiView.ActiveViewIndex += 1; } else if (DevPollMultiView.ActiveViewIndex == 3) { // This is the final view. // The user wants to save the survey results. // Insert code here to save survey results. // Disable the navigation buttons. Page4Save.Enabled = false; Page4Restart.Enabled = false; } else { throw new Exception("An error occurred."); } } protected void BackButton_Command(object sender, EventArgs e) { if (DevPollMultiView.ActiveViewIndex > 0 & DevPollMultiView.ActiveViewIndex <= 2) { // Decrement the ActiveViewIndex property // by one to return to the previous view. DevPollMultiView.ActiveViewIndex -= 1; } else if (DevPollMultiView.ActiveViewIndex == 3) { // This is the final view. // The user wants to restart the survey. // Return to the first view. DevPollMultiView.ActiveViewIndex = 0; } else { throw new Exception("An error occurred."); } } </script> </head> <body> <form ID="Form1" runat="Server"> <h3>MultiView ActiveViewIndex Example</h3> <asp:Panel id="Page1ViewPanel" Width="330px" Height="150px" HorizontalAlign =Left Font-size="12" BackColor="#C0C0FF" BorderColor="#404040" BorderStyle="Double" runat="Server"> <asp:MultiView id="DevPollMultiView" ActiveViewIndex=0 runat="Server"> <asp:View id="Page1" runat="Server"> <asp:Label id="Page1Label" Font-bold="true" Text="What kind of applications do you develop?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page1Radio1" Text="Web Applications" Checked="False" GroupName="RadioGroup1" runat="server" > </asp:RadioButton><br> <asp:RadioButton id="Page1Radio2" Text="Windows Forms Applications" Checked="False" GroupName="RadioGroup1" runat="server" > </asp:RadioButton><br><br><br> <asp:Button id="Page1Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat= "Server"> </asp:Button> </asp:View> <asp:View id="Page2" runat="Server"> <asp:Label id="Page2Label" Font-bold="true" Text="How long have you been a developer?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page2Radio1" Text="Less than five years" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page2Radio2" Text="More than five years" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br><br><br> <asp:Button id="Page2Back" Text = "Previous" OnClick="BackButton_Command" Height="25" Width="70" runat= "Server"> </asp:Button> <asp:Button id="Page2Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat="Server"> </asp:Button> </asp:View> <asp:View id="Page3" runat="Server"> <asp:Label id="Page3Label1" Font-bold="true" Text= "What is your primary programming language?" runat="Server"> </asp:Label><br><br> <asp:RadioButton id="Page3Radio1" Text="Visual Basic .NET" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page3Radio2" Text="C#" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br> <asp:RadioButton id="Page3Radio3" Text="C++" Checked="False" GroupName="RadioGroup1" runat="Server"> </asp:RadioButton><br><br> <asp:Button id="Page3Back" Text = "Previous" OnClick="BackButton_Command" Height="25" Width="70" runat="Server"> </asp:Button> <asp:Button id="Page3Next" Text = "Next" OnClick="NextButton_Command" Height="25" Width="70" runat="Server"> </asp:Button><br> </asp:View> <asp:View id="Page4" runat="Server"> <asp:Label id="Label1" Font-bold="true" Text = "Thank you for taking the survey." runat="Server"> </asp:Label> <br><br><br><br><br><br> <asp:Button id="Page4Save" Text = "Save Responses" OnClick="NextButton_Command" Height="25" Width="110" runat="Server"> </asp:Button> <asp:Button id="Page4Restart" Text = "Retake Survey" OnClick="BackButton_Command" Height="25" Width="110" runat= "Server"> </asp:Button> </asp:View> </asp:MultiView> </asp:Panel> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MultiView クラス
MultiView メンバ
System.Web.UI.WebControls 名前空間
View
SetActiveView
GetActiveView
その他の技術情報
MultiView Web サーバー コントロールおよび View Web サーバー コントロール
Weblioに収録されているすべての辞書からMultiView.ActiveViewIndex プロパティを検索する場合は、下記のリンクをクリックしてください。

- MultiView.ActiveViewIndex プロパティのページへのリンク