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 窗体页中的控件定义了三个 Wizard 向导步骤。 在页面的代码中,向导步骤实例按其 ID 值命名,并且可以在代码中将其引用为 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 窗体页中的特定向导步骤控件。 值 ID 将成为页面中控件实例的名称;这使你可以轻松地访问该页的代码中的特定步骤。 例如,如果将控件WizardStepBase的 属性设置为ID“Step1”,则可以在该页的代码中引用向导步骤的子控件作为 Step1.Controls

控件 WizardStepBase 可确保在设计时添加或修改步骤时控件中的每个 Wizard 步骤都具有有效的唯一标识符。 例如,在设计时为步骤设置 ID 时,它不能与控件中包含的Wizard另一个步骤的标识符匹配,并且它不能与包含Wizard控件的 匹配ID

适用于

另请参阅