Wizard.AllowNavigationToStep(Int32) Wizard.AllowNavigationToStep(Int32) Wizard.AllowNavigationToStep(Int32) Wizard.AllowNavigationToStep(Int32) Method

定義

ブール値を使用して、ActiveStep プロパティを、渡されるインデックスに対応する WizardStepBase オブジェクトに設定できるかどうかを確認します。Uses a Boolean value to determine whether the ActiveStep property can be set to the WizardStepBase object that corresponds to the index that is passed in.

protected:
 virtual bool AllowNavigationToStep(int index);
protected virtual bool AllowNavigationToStep (int index);
abstract member AllowNavigationToStep : int -> bool
override this.AllowNavigationToStep : int -> bool
Protected Overridable Function AllowNavigationToStep (index As Integer) As Boolean

パラメーター

index
Int32 Int32 Int32 Int32

確認する WizardStepBase オブジェクトのインデックス。The index of the WizardStepBase object being checked.

戻り値

渡されたインデックスが、既にアクセスされている WizardStepBase を参照しており、その AllowReturn プロパティが false に設定されている場合は false。それ以外の場合は truefalse if the index passed in refers to a WizardStepBase that has already been accessed and its AllowReturn property is set to false; otherwise, true.

という名前CustomWizardの派生クラスを作成し、 OnSideBarButtonClickメソッドをオーバーライドする方法を次のコード例に示します。The following code example demonstrates how to create a derived class named CustomWizard and override the OnSideBarButtonClick method. CustomWizardコントロールのサイドバー領域のボタンをクリックするとAllowNavigationToStep 、選択した手順にアクセスできるかどうかを判断するためにメソッドが呼び出されます。When a button on the sidebar area of the CustomWizard control is clicked, the AllowNavigationToStep method is called to determine whether the selected step can be accessed. 次に、メッセージが含まれている Web ページに書き込まれ、何が発生したかをユーザーに通知します。A message is then written to the containing Web page informing the user of what has occurred.

<%@ page language="C#"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  // This custom wizard control defines the OnSideBarButtonClick method
  // that uses the AllowNavigationToStep method to determine whether the
  // value passed in can be used to set the ActiveStepIndex property.    
  class CustomWizard : Wizard
  {    
    override protected void OnSideBarButtonClick(WizardNavigationEventArgs e)
    {
      base.OnSideBarButtonClick(e);
      if (AllowNavigationToStep(e.NextStepIndex))
      {
        this.Page.Response.Write("AllowNavigationToStep() returned true, moving to Step" 
          + (e.NextStepIndex + 1).ToString() + ".");
        this.ActiveStepIndex = e.NextStepIndex;
      }
      else
      {
        this.Page.Response.Write("AllowNavigationToStep() returned false for Step" 
          + (e.NextStepIndex + 1).ToString() + ", moving to Step2.");
        this.ActiveStepIndex = 1;
      }
    }         
  }
  
  // Add the custom wizard control to the page.
  void Page_Load(object sender, EventArgs e) 
  {
      CustomWizard WizardControl = new CustomWizard();
      WizardControl.ID = "WizardControl";
      
      // Create some steps for the custom wizard.
      for (int i = 0; i <= 5; i++)
      {
        WizardStep newStep = new WizardStep();
        newStep.ID = "Step" + (i + 1).ToString();
        // Set AllowReturn to false for some of the steps.        
        if ((i % 2) == 0)
        {
          newStep.AllowReturn = false;
        }
        
        // Add each step to the custom wizard.
        WizardControl.WizardSteps.Add(newStep);
      }
            
      // Display the wizard on the page.
      PlaceHolder1.Controls.Add(WizardControl);
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>AllowNavigationToStep Example</title>
</head>
<body>
    <form id="Form1" runat="server">
      <h3>AllowNavigationToStep Example</h3>
      <asp:PlaceHolder id="PlaceHolder1" 
        runat="server" />
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  ' This custom wizard control defines the OnSideBarButtonClick method
  ' that uses the AllowNavigationToStep method to determine whether the
  ' value passed in can be used to set the ActiveStepIndex property.    
  Class CustomWizard
    Inherits Wizard
  
    Protected Overloads Sub OnSideBarButtonClick(ByVal sender As Object, _
      ByVal e As WizardNavigationEventArgs) Handles Me.SideBarButtonClick

      If AllowNavigationToStep(e.NextStepIndex) Then
        
        Me.Page.Response.Write("AllowNavigationToStep() returned true, moving to Step" & _
           (e.NextStepIndex + 1).ToString() & ".")
        Me.ActiveStepIndex = e.NextStepIndex
        
      Else
        
        Me.Page.Response.Write("AllowNavigationToStep() returned false for Step" & _
           (e.NextStepIndex + 1).ToString() & ", moving to Step2.")
        Me.ActiveStepIndex = 1
        
      End If
    End Sub
  End Class
  
  ' Add the custom wizard control to the page.
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    Dim WizardControl As New CustomWizard()
    WizardControl.ID = "WizardControl"
      
    ' Create some steps for the custom wizard.
    For i As Integer = 0 To 5
      Dim newStep As New WizardStep()
      newStep.ID = "Step" & (i + 1).ToString()
      ' Set AllowReturn to false for some of the steps.        
      If ((i Mod 2) = 0) Then
        newStep.AllowReturn = False
      End If
        
      ' Add each step to the custom wizard.
      WizardControl.WizardSteps.Add(newStep)
    Next
      
    ' Display the wizard on the page.
    PlaceHolder1.Controls.Add(WizardControl)
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>AllowNavigationToStep Example</title>
</head>
<body>
    <form id="Form1" runat="server">
      <h3>AllowNavigationToStep Example</h3>
      <asp:PlaceHolder id="PlaceHolder1" 
        runat="server" />
    </form>
  </body>
</html>

注釈

メソッドAllowNavigationToStepには、 protected修飾子があるため、派生クラスからのみアクセスできます。The AllowNavigationToStep method can be accessed from a derived class only because of its protected modifier. 派生クラスでは、 AllowNavigationToStepメソッドを使用して、渡されたインデックスを使用してActiveStepIndexプロパティを設定できるかどうかを判断できます。In a derived class, you can use the AllowNavigationToStep method to determine whether the index that is passed in can be used to set the ActiveStepIndex property. false true false AllowReturn AllowNavigationToStep 渡されたインデックスが既にアクセスされ、そのプロパティがに設定されているオブジェクトを参照している場合、メソッドはを返します。それ以外WizardStepBaseの場合は、を返します。The AllowNavigationToStep method will return false if the index that is passed in refers to a WizardStepBase object that has already been accessed and has its AllowReturn property set to false; otherwise, it will return true.

適用対象

こちらもご覧ください