Export (0) Print
Expand All

WizardStepBase.ID Property

Gets or sets the programmatic identifier assigned to the server control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public override string ID { get; set; }
<asp:WizardStepBase ID="String" />

Property Value

Type: System.String
The programmatic identifier assigned to the control.

ExceptionCondition
ArgumentException

The property was set to an invalid identifier string at design time.

-or-

The property was set to the same identifier as the containing Wizard control at design time.

-or-

The property was set to the same identifier as another step in the containing Wizard control at design time.

Use the ID property to identify and reference a particular wizard step control in a Web Forms page. The ID value becomes the name of the control instance in the page; this allows you to easily access a particular step in code for that page. For example, if you set the ID property of a WizardStepBase control to "Step1", you can reference the child controls of the wizard step in code for that page as Step1.Controls.

The WizardStepBase control ensures that each step in a Wizard control has a valid unique identifier when steps are added or modified at design time. For example, when you set the ID for a step at design time, it cannot match the identifier for another step contained in the Wizard control, and it cannot match the ID for the containing Wizard control.

The following code example defines three wizard steps for a Wizard control in a Web Forms page. In code for the page, the wizard step instances are named by their ID values, and they can be referenced in the code as WizardStep1, WizardStep2, and WizardStep3.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft