Wizard.AllowNavigationToStep(Int32) 메서드

정의

ActiveStep 속성을 전달된 인덱스에 해당하는 WizardStepBase 개체로 설정할 수 있는지 여부를 확인하려면 부울 값을 사용합니다.

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

확인할 WizardStepBase 개체의 인덱스입니다.

반환

Boolean

전달된 인덱스가 이미 액세스한 WizardStepBase를 참조하고 있고 해당 AllowReturn 속성이 false로 설정된 경우 false이며, 그렇지 않으면 true입니다.

예제

다음 코드 예제에서는 명명 CustomWizard 된 파생 클래스를 만들고 메서드를 재정의하는 OnSideBarButtonClick 방법을 보여 줍니다. 컨트롤의 CustomWizard 사이드바 영역에 있는 단추를 클릭하면 AllowNavigationToStep 선택한 단계에 액세스할 수 있는지 여부를 확인하기 위해 메서드가 호출됩니다. 그런 다음, 사용자에게 발생한 내용을 알리는 메시지가 포함된 웹 페이지에 기록됩니다.

<%@ 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 파생 클래스에서만 액세스할 수 있습니다. 파생 클래스에서 이 메서드를 AllowNavigationToStep 사용하여 전달된 인덱스가 속성을 설정하는 ActiveStepIndex 데 사용할 수 있는지 여부를 확인할 수 있습니다. AllowNavigationToStep 전달된 인덱스가 이미 액세스되어 해당 AllowReturn 속성이 설정된 false개체를 참조 WizardStepBase 하면 메서드가 반환 false 되고, 그렇지 않으면 반환true됩니다.

적용 대상

추가 정보