Wizard.ActiveStep 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 WizardSteps 集合中当前显示给用户的步骤。
public:
property System::Web::UI::WebControls::WizardStepBase ^ ActiveStep { System::Web::UI::WebControls::WizardStepBase ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.WizardStepBase ActiveStep { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ActiveStep : System.Web.UI.WebControls.WizardStepBase
Public ReadOnly Property ActiveStep As WizardStepBase
属性值
当前显示给用户的 WizardStepBase。
- 属性
例外
相应的 ActiveStepIndex 小于 -1 或大于 WizardStepBase 中的 Wizard 对象数。
示例
下面的代码示例演示如何使用 ActiveStep 属性来确定将哪个步骤设置为控件的Wizard下一个ActiveStep属性。 如果 的CheckBox1.Checked
true
值为 ,则 ActiveStep 属性设置为 Wizard1.Step3
;否则, ActiveStep 属性设置为 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 if the
// CheckBox1 CheckBox is checked. If it is then skip
// to the Step3 step.
if (Wizard1.ActiveStep == 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="Check this checkbox 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 if the
' CheckBox1 CheckBox is checked. If it is then skip
' to the Step3 step.
If Wizard1.ActiveStep.Equals(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="Check this checkbox 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>
注解
属性 ActiveStep 返回 WizardStepBase 当前显示在 控件中的 Wizard 对象。 属性 ActiveStep 是只读的;但是,可以使用 ActiveStep 属性访问当前 WizardStepBase 对象的属性。 ActiveStepIndex使用 属性动态地将 更改为ActiveStep不同的 WizardStepBase 对象。 或者,可以使用 MoveTo 方法动态设置 ActiveStep 属性。