Wizard.ActiveStepIndex Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit l’index de l’objet actif WizardStepBase .
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é
Index du WizardStepBase contrôle actuellement affiché.Wizard
- Attributs
Exceptions
La valeur sélectionnée est supérieure au nombre d’étapes de l’Assistant définies dans la WizardSteps collection.
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.Checkedtrue, la ActiveStep propriété est définie Wizard1.Step3sur ; sinon, la ActiveStep propriété est définie sur Wizard1.Step2.
<%@ 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 programmation la propriété pour contrôler l’étape ActiveStepIndex affichée à l’utilisateur au moment de l’exécution.
Note
Si vous utilisez Microsoft Visual Studio 2005, notez que celui-ci 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 s’afficher, car elle ActiveStepIndex pointe vers une autre étape.
Si vous définissez la valeur de ActiveStepIndex -1 pour prendre en charge un Assistant sans aucune procédure par défaut, le comportement suivant se produit :
Si vous définissez ActiveStepIndex de manière déclarative sur -1 ou si vous le définissez 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 des thèmes ou des thèmes de feuille de style. Pour plus d’informations, consultez ThemeableAttribute et ASP.NET Thèmes et peaux.