Share via


WizardStepBase.ID 屬性

定義

取得或設定指派給伺服器控制項的程式設計識別項。

public:
 virtual property System::String ^ ID { System::String ^ get(); void set(System::String ^ value); };
public override string ID { get; set; }
member this.ID : string with get, set
Public Overrides Property ID As String

屬性值

指派給控制項的程式設計識別項。

例外狀況

該屬性在設計階段設為無效的識別項字串。

-或-

該屬性在設計階段設為與包含 Wizard 控制項相同的識別項。

-或-

該屬性在設計階段設為與包含 Wizard 控制項中的其他步驟相同的識別項。

範例

下列程式碼範例會為Web Form頁面中的 控制項定義三個 Wizard 精靈步驟。 在頁面的程式碼中,精靈步驟實例會以其識別碼值命名,而且可以在程式碼中將其參考為 WizardStep1WizardStep2WizardStep3

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

備註

ID使用 屬性來識別及參考Web Form頁面中的特定精靈步驟控制項。 值 ID 會變成頁面中控制項實例的名稱;這可讓您輕鬆地存取該頁面程式碼中的特定步驟。 例如,如果您將 ID 控制項的 WizardStepBase 屬性設定為 「Step1」,您可以在該頁面的程式碼中參考精靈步驟的子控制項作為 Step1.Controls

控制項 WizardStepBase 可確保在設計階段新增或修改步驟時,控制項中的每個 Wizard 步驟都有有效的唯一識別碼。 例如,當您在設計階段設定 ID 步驟的 時,它無法比對控制項中包含的另一個步驟的 Wizard 識別碼,而且它不符合 ID 包含 Wizard 控制項的 。

適用於

另請參閱