MultiView.SwitchViewByIndexCommandName フィールド
アセンブリ: System.Web (system.web.dll 内)


SwitchViewByIndexCommandName フィールドを使用して、"SwitchViewByIndex" コマンド名を表します。
このフィールドの値を使用して、MultiView コントロールに備わっている、アクティブな View コントロールの自動更新機能を利用できます。たとえば、クリックされたときに最初の View に移動する Button コントロールが View コントロールに格納されている場合は、CommandName プロパティに SwitchViewByIndexCommandName フィールドの値、つまり "SwitchViewByIndex" を設定できます。CommandArgument プロパティを、MultiView コントロール内の最初の View のインデックス、つまり 0 に設定します。これにより、ボタンがクリックされると、MultiView コントロールは ActiveViewIndex プロパティを自動的に 0 に設定します。

MultiView コントロールを使用して基本調査を作成する方法のコード例を次に示します。各 View コントロールは、個別の調査質問です。PreviousViewCommandName フィールドと NextViewCommandName フィールドは、それぞれに調査の前および次の View コントロールに自動的に移動するために使用します。ユーザーが調査の最後の View の [Retake Survey] ボタンをクリックすると、SwitchViewByIndexCommandName フィールドがコマンド引数 0 と共に使用され、ユーザーは調査の最初の View にリダイレクトして戻されます。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" %> <script runat="server"> Sub Page4SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) ' 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 End Sub </script> <html> <head id="Head1" runat="server"> <title>MultiView.SwitchViewByIndexCommandName Example</title> </head> <body> <form ID="Form1" runat="Server"> <h3>MultiView.SwitchViewByIndexCommandName 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" CommandName="NextView" 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" CommandName="PrevView" Height="25" Width="70" runat= "Server"> </asp:Button> <asp:Button id="Page2Next" Text = "Next" CommandName="NextView" 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" 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" CommandName="PrevView" Height="25" Width="70" runat="Server"> </asp:Button> <asp:Button id="Page3Next" Text = "Next" CommandName="NextView" 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="Page4SaveButton_Click" Height="25" Width="110" runat="Server"> </asp:Button> <asp:Button id="Page4Restart" Text = "Retake Survey" commandname="SwitchViewByIndex" commandargument="0" Height="25" Width="110" runat= "Server"> </asp:Button> </asp:View> </asp:MultiView> </asp:Panel> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page4SaveButton_Click(Object sender, System.EventArgs e) { // 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; } </script> <html> <head id="Head1" runat="server"> <title>MultiView.SwitchViewByIndexCommandName Example</title> </head> <body> <form ID="Form1" runat="Server"> <h3>MultiView.SwitchViewByIndexCommandName 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" CommandName="NextView" 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" CommandName="PrevView" Height="25" Width="70" runat= "Server"> </asp:Button> <asp:Button id="Page2Next" Text = "Next" CommandName="NextView" 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" 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" CommandName="PrevView" Height="25" Width="70" runat="Server"> </asp:Button> <asp:Button id="Page3Next" Text = "Next" CommandName="NextView" 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="Page4SaveButton_Click" Height="25" Width="110" runat="Server"> </asp:Button> <asp:Button id="Page4Restart" Text = "Retake Survey" commandname="SwitchViewByIndex" commandargument="0" 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
SwitchViewByIDCommandName
PreviousViewCommandName
NextViewCommandName
その他の技術情報
MultiView Web サーバー コントロールおよび View Web サーバー コントロール
- MultiView.SwitchViewByIndexCommandName フィールドのページへのリンク