Wizard.MoveTo(WizardStepBase) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的 WizardStepBase-衍生物件設為控制項屬性Wizard的值ActiveStep。
public:
void MoveTo(System::Web::UI::WebControls::WizardStepBase ^ wizardStep);
public void MoveTo(System.Web.UI.WebControls.WizardStepBase wizardStep);
member this.MoveTo : System.Web.UI.WebControls.WizardStepBase -> unit
Public Sub MoveTo (wizardStep As WizardStepBase)
參數
- wizardStep
- WizardStepBase
WizardStepBase要設定為 的 -導出物件為 ActiveStep。
例外狀況
傳遞入的 -導出物件的值 WizardStepBase為 null。
所傳遞的相關 WizardStepBase-導出物件的 為 ActiveStepIndex -1。
範例
以下程式碼範例示範如何使用該 MoveTo 方法來控制 ActiveStep 控制項的 Wizard 屬性。 若 的 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 whether the
// CheckBox1 check box is selected. If it is, skip to the Step3 step.
if (Wizard1.ActiveStepIndex == Wizard1.WizardSteps.IndexOf(this.WizardStep2))
{
if (this.CheckBox1.Checked)
{
Wizard1.MoveTo(this.WizardStep3);
}
else
{
Wizard1.MoveTo(this.WizardStep2);
}
}
}
</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>MoveTo 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 check box 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.MoveTo(Me.WizardStep3)
Else
Wizard1.MoveTo(Me.WizardStep2)
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>MoveTo Example</b>
</HeaderTemplate>
</asp:Wizard>
</form>
</body>
</html>
備註
使用該MoveTo方法來程式化控制 WizardStepBase-derived 物件被設定為 control 屬性Wizard的值ActiveStep。 這樣一來,你可以在執行時根據其他條件動態改變屬性 ActiveStep 。