Wizard クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説
Wizard コントロールを使用すると、以下の処理を実行できます。
Wizard コントロールは、次のコンポーネントで構成されます。
Wizard コントロール内の各ステップには、ステップのナビゲーション機能の種類を決定する StepType プロパティがあります。StepType プロパティに値を指定しなかった場合、既定値は Auto になります。StepType プロパティに指定できる設定と、各設定でのステップの動作を次の表に示します。
WizardStepType.Autoあるステップに表示されるナビゲーション UI は、そのステップが宣言されている順序によって決定されます。
WizardStepType.Complete最後に表示されるステップです。ナビゲーション ボタンは表示されません。
WizardStepType.Finishユーザー データを収集する最後のステップです。ナビゲーション用に [完了] ボタンが表示されます。
WizardStepType.Start最初に表示されるステップです。[戻る] ボタンは表示されません。
WizardStepType.Step最初のステップと最後のステップの間のステップです。ナビゲーション用に [戻る] ボタンと [次へ] ボタンが表示されます。
Wizard コントロールを使用すると、直線的または非直線的なナビゲーションによってデータを収集できます。非直線的なナビゲーションの例としては、不要なステップのスキップや、以前に完了したステップに戻っての値の変更などがあります。Wizard コントロールはステップ間の状態を保持するため、Wizard コントロールのすべてのステップが完了するまでは、ステップで入力されたデータをデータ ストアに永続化する必要はありません。
NextButtonClick イベントが発生したときなど、各ステップの完了時に収集済みデータをデータ ストアに永続化する場合は、WizardStepBase オブジェクトの AllowReturn プロパティを false に設定して、データが送信された後は、ユーザーが以前に完了したステップに戻ってデータを変更できないようにする必要があります。
MoveTo メソッドまたは ActiveStepIndex プロパティを使用すると、Wizard コントロールに現在表示されているステップを動的に変更できます。
メモ |
---|
プログラムによって Page_Load イベント ハンドラに WizardStep を追加する場合は、ページの読み込み前にその手順へのナビゲーションを追加する必要があります。 |
Wizard コントロールの外観は、テンプレート、スキン、およびスタイル設定によって完全にカスタマイズできます。たとえば、HeaderTemplate、SideBarTemplate、StartNavigationTemplate、FinishNavigationTemplate、および StepNavigationTemplate の各プロパティを使用して、Wizard コントロールのインターフェイスをカスタマイズできます。
メモ |
---|
FinishNavigationTemplate、DisplaySideBar、HeaderTemplate、SideBarTemplate、StartNavigationTemplate、または StepNavigationTemplate の各プロパティを設定すると、Wizard コントロールの子コントロールが再作成されます。その結果、子コントロールのビューステートが処理中に失われます。この状況を回避するには、Wizard コントロールの子コントロールの状態を明示的に保持するか、コントロールをテンプレートの内部に入れないようにします。 |
Wizard コントロールは、非標準モードまたは互換捻出モードにおける Microsoft Internet Explorer での特別なレンダリングをサポートしていません。Wizard コントロールを使用して Internet Explorer での最適なレンダリングを実現するには、既定で Visual Web Developer および Visual Studio に追加されている XHTML ドキュメント タイプを使用します。
ユーザー補助
このコントロールに既定でレンダリングされるマークアップは、Web Content Accessibility Guidelines (WCAG) 1.0 の優先度 1 ガイドラインなどのユーザー補助に関する標準に適合しない可能性があります。たとえば、CancelDestinationPageUrl または FinishDestinationPageUrl を使用するとページが更新されますが、これは、ページ上のボタンやリンクをクリックしたときにページが更新されてはいけないというユーザー補助要件に反しています。このコントロールのユーザー補助サポートの詳細については、「ASP.NET コントロールとユーザー補助」を参照してください。
Wizard コントロールを定義し、個別の送付先を入力するオプション付きで、ユーザーの名前と住所を収集する方法を次のコード例に示します。ユーザーが [SeparateShippingCheckBox] を選択しなかった場合、個別の送付先を追加する要求が発行され、Wizard コントロールは Step2 から Finish に直接移動します。Finish ステップでは、[GoBackButton] をクリックして Wizard コントロールの先頭に戻るためのオプションがあります。ただし、Step1 の AllowReturn プロパティが false に設定されているため、ユーザーは Step2 に戻ります。
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WizardClass.vb" Inherits="WizardClassvb_aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <body> <form id="form1" runat="server"> <asp:Wizard id="Wizard1" runat="server" onfinishbuttonclick="OnFinishButtonClick" backcolor="#EFF3FB" font-names="Verdana" font-size="0.8em" borderwidth="1px" bordercolor="#B5C7DE" style="font-size: medium; font-family: Verdana;" onactivestepchanged="OnActiveStepChanged"> <StepStyle forecolor="#333333" font-size="0.8em" /> <WizardSteps> <asp:WizardStep id="Step1" title="One" allowreturn="false" runat="server" > Welcome to the Wizard example. This step's AllowReturn property is set to false, so after you leave this step you will not be able to return to it. </asp:WizardStep> <asp:WizardStep id="Step2" title="Two" runat="server" > <!-- ... Put UI elements here ... --> Please enter your billing information. <br /> Name:<br /> <asp:TextBox runat="server" id="BillingName" width="226px" height="17px" /> <br /> Email Address:<br /> <asp:TextBox runat="server" id="EmailAddress" width="224px" height="17px" /> <br /> Address Line 1: <br /> <asp:TextBox runat="server" id="BillingAddressLine1" width="314px" height="17px" /> <br /> Address Line 2: <br /> <asp:TextBox runat="server" id="BillingAddressLine2" width="314px" height="17px" /> <br /> City: <br /> <asp:TextBox runat="server" id="BillingCity" width="155px" height="17px" /> <br /> State: <br /> <asp:TextBox runat="server" id="BillingState" width="75px" height="17px" /> <br /> ZIP Code: <br /> <asp:TextBox runat="server" id="BillingZip" height="17px" /> <br /><br /> <asp:CheckBox runat="server" id="SeparateShippingCheckBox" text="Please check here if you would like to add a separate shipping address." /> </asp:WizardStep> <asp:WizardStep id="Step3" title="Three" runat="server" > <!-- Gather the shipping address in this step if CheckBox1 was selected. --> Please enter your shipping information. <br /> Name:<br /> <asp:TextBox runat="server" id="ShippingName" height="17px" /> <br /> Address Line 1: <br /> <asp:TextBox runat="server" id="ShippingAddress1" width="370px" height="17px" /> <br /> Address Line 2: <br /> <asp:TextBox runat="server" id="ShippingAddress2" width="370px" height="17px" /> <br /> City: <br /> <asp:TextBox runat="server" id="ShippingCity" height="17px" /> <br /> State: <br /> <asp:TextBox runat="server" id="ShippingState" width="65px" height="17px" /> <br /> ZIP Code: <br /> <asp:TextBox runat="server" id="ShippingZip" height="17px" /> </asp:WizardStep> <asp:WizardStep id="Finish" title="Finish" runat="server" > <!-- Put UI elements here for the Finish step. --> <asp:Button runat="server" id="GoBackButton" text="Go Back to Step 2" forecolor="#284E98" font-names="Verdana" font-size="1.0em" borderstyle="Solid" borderwidth="1px" bordercolor="#507CD1" backcolor="White" /> </asp:WizardStep> <asp:WizardStep runat="server" steptype="Complete" title="Complete" id="Complete"> <asp:Label runat="server" id="CompleteMessageLabel" width="408px" height="24px"> </asp:Label> </asp:WizardStep> </WizardSteps> <NavigationButtonStyle forecolor="#284E98" font-names="Verdana" font-size="1.0em" borderstyle="Solid" borderwidth="1px" bordercolor="#507CD1" backcolor="White" /> <HeaderStyle forecolor="White" horizontalalign="Center" font-size="0.9em" font-bold="True" backcolor="#284E98" borderstyle="Solid" bordercolor="#EFF3FB" borderwidth="2px" /> <SideBarStyle verticalalign="Top" horizontalalign="Center" font-size="0.8em" forecolor="#000099" backcolor="#EFF3FB" width="45px" /> <HeaderTemplate> <b>Wizard Example</b> </HeaderTemplate> </asp:Wizard> </form> </body> </html>
<%@ Page Language="C#" CodeFile="WizardClass.cs" Inherits="WizardClasscs_aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <body> <form id="form1" runat="server"> <asp:Wizard id="Wizard1" runat="server" onfinishbuttonclick="OnFinishButtonClick" backcolor="#EFF3FB" font-names="Verdana" font-size="0.8em" borderwidth="1px" bordercolor="#B5C7DE" style="font-size: medium; font-family: Verdana;" onactivestepchanged="OnActiveStepChanged"> <StepStyle forecolor="#333333" font-size="0.8em" /> <WizardSteps> <asp:WizardStep id="Step1" title="One" allowreturn="false" runat="server" > Welcome to the Wizard example. This step's AllowReturn property is set to false, so after you leave this step you will not be able to return to it. </asp:WizardStep> <asp:WizardStep id="Step2" title="Two" runat="server" > <!-- ... Put UI elements here ... --> Please enter your billing information. <br /> Name:<br /> <asp:TextBox runat="server" id="BillingName" width="226px" height="17px" /> <br /> E-mail Address:<br /> <asp:TextBox runat="server" id="EmailAddress" width="224px" height="17px" /> <br /> Address Line 1: <br /> <asp:TextBox runat="server" id="BillingAddressLine1" width="314px" height="17px" /> <br /> Address Line 2: <br /> <asp:TextBox runat="server" id="BillingAddressLine2" width="314px" height="17px" /> <br /> City: <br /> <asp:TextBox runat="server" id="BillingCity" width="155px" height="17px" /> <br /> State: <br /> <asp:TextBox runat="server" id="BillingState" width="75px" height="17px" /> <br /> ZIP Code: <br /> <asp:TextBox runat="server" id="BillingZip" height="17px" /> <br /><br /> <asp:CheckBox runat="server" id="SeparateShippingCheckBox" text="Please check here if you would like to add a separate shipping address." /> </asp:WizardStep> <asp:WizardStep id="Step3" title="Three" runat="server" > <!-- Gather the shipping address in this step if CheckBox1 was selected. --> Please enter your shipping information. <br /> Name:<br /> <asp:TextBox runat="server" id="ShippingName" height="17px" /> <br /> Address Line 1: <br /> <asp:TextBox runat="server" id="ShippingAddress1" width="370px" height="17px" /> <br /> Address Line 2: <br /> <asp:TextBox runat="server" id="ShippingAddress2" width="370px" height="17px" /> <br /> City: <br /> <asp:TextBox runat="server" id="ShippingCity" height="17px" /> <br /> State: <br /> <asp:TextBox runat="server" id="ShippingState" width="65px" height="17px" /> <br /> ZIP Code: <br /> <asp:TextBox runat="server" id="ShippingZip" height="17px" /> </asp:WizardStep> <asp:WizardStep id="Finish" title="Finish" runat="server" > <!-- Put UI elements here for the Finish step. --> <asp:Button runat="server" id="GoBackButton" text="Go Back to Step 2" onclick="OnGoBackButtonClick" forecolor="#284E98" font-names="Verdana" font-size="1.0em" borderstyle="Solid" borderwidth="1px" bordercolor="#507CD1" backcolor="White" /> </asp:WizardStep> <asp:WizardStep runat="server" steptype="Complete" title="Complete" id="Complete"> <asp:Label runat="server" id="CompleteMessageLabel" width="408px" height="24px"> </asp:Label> </asp:WizardStep> </WizardSteps> <NavigationButtonStyle forecolor="#284E98" font-names="Verdana" font-size="1.0em" borderstyle="Solid" borderwidth="1px" bordercolor="#507CD1" backcolor="White" /> <HeaderStyle forecolor="White" horizontalalign="Center" font-size="0.9em" font-bold="True" backcolor="#284E98" borderstyle="Solid" bordercolor="#EFF3FB" borderwidth="2px" /> <SideBarStyle verticalalign="Top" horizontalalign="Center" font-size="0.8em" forecolor="#000099" backcolor="#EFF3FB" width="45px" /> <HeaderTemplate> <b>Wizard Example</b> </HeaderTemplate> </asp:Wizard> </form> </body> </html>
前の例で使用された Web ページに対する分離コード ファイルを次のコード例に示します。
Partial Class WizardClassvb_aspx Inherits System.Web.UI.Page Protected Sub OnFinishButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick ' The OnFinishButtonClick method is a good place to collect all ' the data from the completed pages and persist it to the data store. ' For this example, write a confirmation message to the Complete page ' of the Wizard control. Dim tempLabel As Label = CType(Wizard1.FindControl("CompleteMessageLabel"), Label) If Not tempLabel Is Nothing Then Dim tempEmailAddress As String = "your e-mail address" If EmailAddress.Text.Length <> 0 Then tempEmailAddress = EmailAddress.Text End If tempLabel.Text = "Your order has been placed. An e-mail confirmation will be sent to " & _ tempEmailAddress & "." End If End Sub Protected Sub OnGoBackButtonClick(ByVal sender As Object, ByVal e As EventArgs) Handles GoBackButton.Click ' The GoBackButtonClick event is raised when the GoBackButton ' is clicked on the Finish page of the Wizard. ' Check the value of Step1's AllowReturn property. If Step1.AllowReturn Then ' Return to Step1. Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.Step1) Else ' Step1 is not a valid step to return to; go to Step2 instead. Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.Step2) Response.Write("ActiveStep is set to Step2 because Step1 has AllowReturn set to false.") End If End Sub Protected Sub OnActiveStepChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Wizard1.ActiveStepChanged ' If the ActiveStep is changing to Step3, check to see whether the ' SeparateShippingCheckBox is selected. If it is not, skip to the ' Finish step. If (Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.Step3)) Then If (Me.SeparateShippingCheckBox.Checked) Then Wizard1.MoveTo(Me.Step3) Else Wizard1.MoveTo(Me.Finish) End If End If End Sub End Class
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class WizardClasscs_aspx : System.Web.UI.Page { protected void OnFinishButtonClick(Object sender, WizardNavigationEventArgs e) { // The OnFinishButtonClick method is a good place to collect all // the data from the completed pages and persist it to the data store. // For this example, write a confirmation message to the Complete page // of the Wizard control. Label tempLabel = (Label)Wizard1.FindControl("CompleteMessageLabel"); if (tempLabel != null) { tempLabel.Text = "Your order has been placed. An e-mail confirmation will be sent to " + (EmailAddress.Text.Length == 0 ? "your e-mail address" : EmailAddress.Text) + "."; } } protected void OnGoBackButtonClick(object sender, EventArgs e) { // The GoBackButtonClick event is raised when the GoBackButton // is clicked on the Finish page of the Wizard. // Check the value of Step1's AllowReturn property. if (Step1.AllowReturn) { // Return to Step1. Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.Step1); } else { // Step1 is not a valid step to return to; go to Step2 instead. Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.Step2); Response.Write("ActiveStep is set to Step2 because Step1 has AllowReturn set to false."); } } protected void OnActiveStepChanged(object sender, EventArgs e) { // If the ActiveStep is changing to Step3, check to see whether the // SeparateShippingCheckBox is selected. If it is not, skip to the // Finish step. if (Wizard1.ActiveStepIndex == Wizard1.WizardSteps.IndexOf(this.Step3)) { if (this.SeparateShippingCheckBox.Checked) { Wizard1.MoveTo(this.Step3); } else { Wizard1.MoveTo(this.Finish); } } } }
System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.CompositeControl
System.Web.UI.WebControls.Wizard
System.Web.UI.WebControls.CreateUserWizard
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Wizard メンバ
System.Web.UI.WebControls 名前空間
CompositeControl クラス
Control
その他の技術情報
Wizard Web サーバー コントロール
Wizard Web サーバー コントロールの概要
- Wizard クラスのページへのリンク