Wizard.ActiveStepIndex Propriété

Définition

Obtient ou définit l'index de l'objet WizardStepBase actuel.

public:
 virtual property int ActiveStepIndex { int get(); void set(int value); };
[System.Web.UI.Themeable(false)]
public virtual int ActiveStepIndex { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.ActiveStepIndex : int with get, set
Public Overridable Property ActiveStepIndex As Integer

Valeur de propriété

Int32

Index de l'objet WizardStepBase qui est actuellement affiché dans le contrôle Wizard.

Attributs

Exceptions

La valeur sélectionnée est plus haute que le nombre d'étapes d'Assistant défini dans la collection WizardSteps.

Exemples

L’exemple de code suivant montre comment utiliser la ActiveStepIndex propriété pour définir la ActiveStep propriété du Wizard contrôle. Si la valeur est CheckBox1.Checked true, la ActiveStep propriété est définie Wizard1.Step3sur ; sinon, la ActiveStep propriété est définie Wizard1.Step2sur .

<%@ 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">

  void OnActiveStepChanged(object sender, EventArgs e)
  {
    // If the ActiveStep is changing to Step2, check to see whether the 
    // CheckBox1 CheckBox is selected.  If it is, skip to the Step2 step.
    if (Wizard1.ActiveStepIndex == Wizard1.WizardSteps.IndexOf(this.WizardStep2))
    {
      if (this.CheckBox1.Checked)
      {
        Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.WizardStep3);
      }
    }
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
      <form id="form1" runat="server">
        <asp:Wizard id="Wizard1" 
          runat="server"
          OnActiveStepChanged="OnActiveStepChanged">
          <WizardSteps>
            <asp:WizardStep id="WizardStep1" 
              title="Step 1" 
              runat="server">
              <asp:CheckBox id="CheckBox1" 
                runat="Server" 
                text="Select this check box to skip Step 2." />
                You are currently on Step 1.
            </asp:WizardStep>
            <asp:WizardStep id="WizardStep2" 
              title="Step 2" 
              runat="server">
              You are currently on Step 2.
            </asp:WizardStep>
            <asp:WizardStep id="WizardStep3" 
              runat="server" 
              title="Step 3">
              You are currently on Step 3.
            </asp:WizardStep>
          </WizardSteps>
          <HeaderTemplate>
            <b>ActiveStepIndex Example</b>
          </HeaderTemplate>
        </asp:Wizard>
      </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">

  Sub OnActiveStepChanged(ByVal sender As Object, ByVal e As EventArgs)
    ' If the ActiveStep is changing to Step2, check to see whether the 
    ' CheckBox1 CheckBox is selected.  If it is, skip to the Step3 step. 
    If (Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.WizardStep2)) Then
      If (Me.CheckBox1.Checked) Then
        Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.WizardStep3)
      End If
    End If
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
      <form id="form1" runat="server">
        <asp:Wizard id="Wizard1" 
          runat="server"
          OnActiveStepChanged="OnActiveStepChanged">
          <WizardSteps>
            <asp:WizardStep id="WizardStep1" 
              title="Step 1" 
              runat="server">
              <asp:CheckBox id="CheckBox1" 
                runat="Server" 
                text="Select this check box to skip Step 2." />
                You are currently on Step 1.
            </asp:WizardStep>
            <asp:WizardStep id="WizardStep2" 
              title="Step 2" 
              runat="server">
              You are currently on Step 2.
            </asp:WizardStep>
            <asp:WizardStep id="WizardStep3" 
              runat="server" 
              title="Step 3">
              You are currently on Step 3.
            </asp:WizardStep>
          </WizardSteps>
          <HeaderTemplate>
            <b>ActiveStepIndex Example</b>
          </HeaderTemplate>
        </asp:Wizard>
      </form>
  </body>
</html>

Remarques

La ActiveStepIndex propriété fournit l’index de base zéro de l’objet WizardStepBase actuellement affiché dans le Wizard contrôle. Vous pouvez définir par programme la ActiveStepIndex propriété pour contrôler l’étape affichée à l’utilisateur au moment de l’exécution.

Notes

Si vous utilisez Microsoft Visual Studio 2005, notez que l’élément ActiveStepIndex est conservé en mode Source. Si vous modifiez la WizardSteps propriété en mode Création en cliquant sur les boutons de la barre latérale, puis que vous exécutez la page, la première étape du Wizard contrôle peut ne pas être affichée, car elle ActiveStepIndex pointe peut-être vers une autre étape.

Si vous définissez la valeur de ActiveStepIndex -1 pour prendre en charge un Assistant sans étapes par défaut, le comportement suivant se produit :

  • Si vous définissez ActiveStepIndex de manière déclarative -1 ou définissez-le sur -1 comme valeur par défaut, le contrôle essaie toujours d’afficher la première étape de l’Assistant.

  • Si vous définissez ActiveStepIndex par programmation sur -1, le contrôle ne s’affiche pas.

Cette propriété ne peut pas être définie par les thèmes ou les thèmes de feuille de style. Pour plus d’informations, consultez ThemeableAttribute et ASP.NET thèmes et apparences.

S’applique à

Voir aussi